Click event for specific cell in datagridview vb.net

23,335

In you dataGridView Event "DataGridView1_CellClick" add this code :

  Private Sub DataGridView1_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellClick

    If e.ColumnIndex = 2 And e.RowIndex = 8 Then
        'Do any thing

        MsgBox("yes" + DataGridView1.Item(e.ColumnIndex, e.RowIndex).Value.ToString())

    End If
End Sub
Share:
23,335
TM80
Author by

TM80

Updated on February 23, 2020

Comments

  • TM80
    TM80 about 4 years

    I have a cell in a datagridview its located at the 8th row 2nd column That cell and that cell only if clicked I want to show as save as dialoguebox but I can actually get a click event happening for a specific cell how do I do this in vb.net?

  • AMDarwech
    AMDarwech over 4 years
    a bit late, but lets say I want to call this event from another event (lets say a DataBindingComplete) event so that I can automatically click on the first element of the freshly loaded DGV how would I call the cell click event?