RightClick in a DataGrid

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I determine which cell a user has right clicked in?

I want to use a ContextMenu to offer the user a simple Add, Edit, Delete menu option, but I need to detemine which cell the user has right clicked in so that I can set up the necessary code.
 
'Row Cell Click
Private Sub DataGrid1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles DataGrid1.MouseDown
Dim myGrid As DataGrid = CType(sender, DataGrid)
Dim hti As System.Windows.Forms.DataGrid.HitTestInfo
hti = myGrid.HitTest(e.X, e.Y)
Select Case hti.Type
Case System.Windows.Forms.DataGrid.HitTestType.Cell
If (hti.Column = 0) Then
If Not (hti.Row = intGridLength) Then
strSearchDealnumber = DataGrid1.Item(hti.Row, hti.Column)

BrianDH
 
Thanks for this Brian, but can I ask what the "intGridLength" variable is and what you have set it to?
 
Back
Top