Murray Brown
asked on
VB.net Right click on DataGridView
Hi
In the code below, which I found at the bottom of the following page
http://www.codeproject.com/Questions/518882/vb-net-2cplusDatagridViewplusContextplusMenuplusSt
The Context Menu Strip isn't showing. How do I get it to pop up at the right click point
and how do I run code to delete a cell?
Private Sub DgvDelays_CellMouseClick(B yVal sender As Object, ByVal e As System.Windows.Forms.DataG ridViewCel lMouseEven tArgs) Handles DgvDelays.CellMouseDown
Dim rowClicked As DataGridView.HitTestInfo = DgvDelays.HitTest(e.X, e.Y)
'Select Right Clicked Row if its not the header row
If e.Button = Windows.Forms.MouseButtons .Right AndAlso e.RowIndex > -1 Then
'Clear any currently sellected rows
DgvDelays.ClearSelection()
Me.DgvDelays.Rows(e.RowInd ex).Select ed = True
CmsRightClick.Show(DgvDela ys, New System.Drawing.Point(Mouse X, MouseY))
End If
End Sub
In the code below, which I found at the bottom of the following page
http://www.codeproject.com/Questions/518882/vb-net-2cplusDatagridViewplusContextplusMenuplusSt
The Context Menu Strip isn't showing. How do I get it to pop up at the right click point
and how do I run code to delete a cell?
Private Sub DgvDelays_CellMouseClick(B
Dim rowClicked As DataGridView.HitTestInfo = DgvDelays.HitTest(e.X, e.Y)
'Select Right Clicked Row if its not the header row
If e.Button = Windows.Forms.MouseButtons
'Clear any currently sellected rows
DgvDelays.ClearSelection()
Me.DgvDelays.Rows(e.RowInd
CmsRightClick.Show(DgvDela
End If
End Sub
ASKER
Thanks James. How do I get it to pop up with a button on it that runs some code?
I do not understand your last question.
What do you want to pop up? A ContextMenuStrip? There are no "buttons" on a ContextMenuStrip, only menu items.
Do you already have a ContextMenuStrip on your form?
What do you want to pop up? A ContextMenuStrip? There are no "buttons" on a ContextMenuStrip, only menu items.
Do you already have a ContextMenuStrip on your form?
ASKER
Hi
Yes please I need a ContextMenuStrip to pop up....I aready have one on my form. I just need the user to be able to clear the content of the cell
Yes please I need a ContextMenuStrip to pop up....I aready have one on my form. I just need the user to be able to clear the content of the cell
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks very much
I suspect that CmsRightClick is a ContextMenuStrip, but it is not defined anywhere in the code.