Hi,
I just realised that the currentcell property (and the currentrow property) doesn't necessarily mean the clicked cell is the current cell.
I need to get the index of the cell that the user right-clicked, but now I get the "active" cell instead. How do I get the cell that is clicked?
Thanks a lot!
Pettrer (Datagridview, VB.Net)
I just realised that the currentcell property (and the currentrow property) doesn't necessarily mean the clicked cell is the current cell.
I need to get the index of the cell that the user right-clicked, but now I get the "active" cell instead. How do I get the cell that is clicked?
VB.NET:
Private Sub MyDGV_CellMouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles MyDGV.CellMouseDown
If e.Button = MouseButtons.Right Then
If MyDGV.CurrentCell.ColumnIndex = COL_FIRSTNAME Or MyDGV.CurrentCell.ColumnIndex = COL_LASTNAME Then
'Adds context menus
MyDGV.Tag = MyDGV.CurrentRow.Cells(COL_STUDID).Value
MyDGV.CurrentCell.ContextMenuStrip = UcCmPerson2.cmPerson
End If
End If
End Sub
Thanks a lot!
Pettrer (Datagridview, VB.Net)