Posted by: Sourav | June 1, 2015

Show the name in textbox when click on gridview,VB.Net


So on the the last post I have achieved when user type s in the delete textbox the gridview showing all the name starting with s,Suppose there are three records have

names like Sourav1,Sourav2 and Sourav3,Now I want if the user click on Sourav2,The delebox should show Sourav2 instead of s

Private Sub DataGridView3_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView3.CellClick
        If e.RowIndex >= 0 Then
            Dim row As DataGridViewRow
            row = Me.DataGridView3.Rows(e.RowIndex)
            TextBox7.Text = RTrim((row.Cells(“Name”).Value.ToString))
        End If

    End Sub

 Private Sub DataGridView3_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView3.CellContentClick
        If e.RowIndex > 0 Then
            Dim row As DataGridViewRow
            row = Me.DataGridView3.Rows(e.RowIndex)
            TextBox7.Text = (row.Cells(“Name”).Value.ToString)
        End If
    End Sub

I put the same codes on both cellclick and cellcontentclick event just to be safe,I think the cellclick event should do just fine

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: