CONTEXTMENU

  • Thread starter Thread starter Stever1975
  • Start date Start date
S

Stever1975

I know how to add menuitems: contextMenu1.MenuItems.Add(menuItem1)
But how do you put an event handler at the level of contextmenu that
which tells you which item has been clicked.
The reason I want to this is a want to link all the menuitems to the
same function, and that function is going to take menuitem.text as a
parameter.

thanks
Steve
 
I know how to add menuitems: contextMenu1.MenuItems.Add(menuItem1)
But how do you put an event handler at the level of contextmenu that
which tells you which item has been clicked.
The reason I want to this is a want to link all the menuitems to the
same function, and that function is going to take menuitem.text as a
parameter.

thanks
Steve

If i understood correctly, that must be what you're looking for:

Private Sub ContextMenuStrip1_itemclick(ByVal sender As System.Object,
ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles
ContextMenuStrip1.ItemClicked
MsgBox(e.ClickedItem.Name.ToString)
End Sub

HTH,

Onur
 
If i understood correctly, that must be what you're looking for:

Private Sub ContextMenuStrip1_itemclick(ByVal sender As System.Object,
ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles
ContextMenuStrip1.ItemClicked
MsgBox(e.ClickedItem.Name.ToString)
End Sub

HTH,

Onur

Adiitionaly,

Or you may want to get item's text instead of item's name, then do
this;

Private Sub ContextMenuStrip1_itemclick(ByVal sender As System.Object,
ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles
ContextMenuStrip1.ItemClicked
MsgBox(e.ClickedItem.Text.ToString)
End Sub

Hope this helps,

Onur
 
Back
Top