AfterShotzZHD
AfterShotzZHD

Reputation: 321

Check to see if a certain cell has been selected in DataGridView?

I have a dataGridView. I will post a picture of it.

http://i.imgur.com/fgtlXyD.png

I am wanting to know how I could execute code on selection of each member name.

Upvotes: 0

Views: 1742

Answers (1)

Júlio Murta
Júlio Murta

Reputation: 545

You can use the CellClik event and check if the column index is the desired column. For example:

Private Sub DataGridView1_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellClick
    If e.ColumnIndex = 1 Then
        MessageBox.Show(DataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value)
    End If
End Sub

Upvotes: 2

Related Questions