Convert 1 of datagridview columns to uppercase

I have a datagridview with several columns. I want to change only 1 of those columns to uppercase.
Sample code would be appreciated.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Om PrakashCommented:
Private Sub DataGridView1_EditingControlShowing(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles DataGridView1.EditingControlShowing
        If TypeOf e.Control Is TextBox Then
            DirectCast(e.Control, TextBox).CharacterCasing = CharacterCasing.Upper
        End If
    End Sub
in you gridView Row databound event do the following
change the yourGridView to the name of your gridview and the desiredindex t to an integer value indication the position of the colum you want to change

 Private Sub YourGridView_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles YourGridView.RowDataBound
  If e.Row.RowType = DataControlRowType.DataRow Then   
 e.Row.Cells(DesiredIndex).Text = e.Row.Cells(DesiredIndex).Text.toUpper

        End If

End sub

Open in new window

use LoadingRow event


private void YourGrid_LoadingRow(object sender, System.Windows.Controls.DataGridRowEventArgs e)
TextBlock txt = this.YourGrid.Columns[YourRow].GetCellContent(e.Row) as TextBlock;
//txt.Text = set your uppercase text
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

dave_skyAuthor Commented:

I am getting the errors:
Event RowDataBound cannot be found.
Name 'DataControlRowTyoe isnot declared
is trhis an application or windows?
dave_skyAuthor Commented:

in your form_Load Event
add the following code, replace 2 by the desired column you would like to modify
     For Each r As DataGridViewRow In DataGridView1.Rows
            If Not r.Cells(2).Value Is Nothing Then
                r.Cells(2).Value = r.Cells(2).Value.ToString.ToUpper
            End If


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dave_skyAuthor Commented:
The code worked ok in BindingNavigatorSaveItem also.
I tried various things to get the text to change on entry with no luck
dave_skyAuthor Commented:
Thank you!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.