Tailorware
New member
- Joined
- Feb 12, 2012
- Messages
- 2
- Programming Experience
- 5-10
I want to add a context menu to a datagrid in VB2008 and I need to find out which menu item the user selected.
I don't want to use the ContextMenuStrip that's available in the toolbox since it doesn't allow for dynamic placement depending on what row is active in the grid (I haven't found a Top and Left property in the ContextMenuStrip)
Here's what I've got so far, I'm aware of the fact that the MsgBox uses a non-existing property, it is meant to show my intention.
Given the available properties in the ContextMenu object, I would think that there would be something like a SelectedItemCaption property but a search of the object tree yields no results. What should I use?
Thanks in advance,
Henk
I don't want to use the ContextMenuStrip that's available in the toolbox since it doesn't allow for dynamic placement depending on what row is active in the grid (I haven't found a Top and Left property in the ContextMenuStrip)
Here's what I've got so far, I'm aware of the fact that the MsgBox uses a non-existing property, it is meant to show my intention.
Given the available properties in the ContextMenu object, I would think that there would be something like a SelectedItemCaption property but a search of the object tree yields no results. What should I use?
Thanks in advance,
Henk
VB.NET:
dim grdContextMenu as ContextMenu
grdContextMenu = New ContextMenu
grdContextMenu.MenuItems.Add("Insert")
grdcontextMenu.MenuItems.Add("Update")
grdcontextMenu.MenuItems.Add("Delete")
If e.Button = Windows.Forms.MouseButtons.Right Then
grdcontextMenu.Show(grdCursisten, New Point(MousePosition.X - 25, MousePosition.Y - 50))
MsgBox(grdcontextMenu.SelectedItemCaption)
End If