You can get the functionality you want by relying on the CellClick
event. Sample code for DataGridView1
:
Private Sub DataGridView1_CellClick(sender As Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick
If (e.ColumnIndex > -1 AndAlso e.RowIndex > -1 AndAlso e.ColumnIndex + 1 <= DataGridView1.Columns.Count - 1) Then
Dim cell As DataGridViewCell = DataGridView1(e.ColumnIndex + 1, e.RowIndex)
If (cell.Value IsNot Nothing) Then MessageBox.Show(cell.Value.ToString())
End If
End Sub
This code works with every column (except, logically, with the last one); you have to adapt it to work just with the column(s) you wish.