By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,219 Members | 2,361 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,219 IT Pros & Developers. It's quick & easy.

RightClick in a DataGrid

P: n/a
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.
Nov 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
'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

"Supa Hoopsa" wrote:
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.

Nov 20 '05 #2

P: n/a
Thanks for this Brian, but can I ask what the "intGridLength" variable is and what you have set it to?

"BrianDH" wrote:
'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

"Supa Hoopsa" wrote:
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.

Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.