CONTEXTMENU

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
 
K

kimiraikkonen

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
 
K

kimiraikkonen

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top