Context Menu

  • Thread starter Thread starter tm
  • Start date Start date
T

tm

I have added a ContextMenuStrip to my form and assigned
several controls to it.

My question is how can I retrieve the menu item that has been
clicked with in the ContextMenuStrip1_Click event and also
how do I find the calling control that clicked the menu item?

Thanks
 
Each menu item in the context menu will have it's own click event. If
you are designing your context menu at design time, simply double click
on the item and it will give you the code. If you are dynamically
adding the menuitems at run time, use this...

cmuContext.MenuItems.Add(New MenuItem(MenuText, AddressOf
ClickHandler))

where the click handler is a method that you have written. The click
handler can take parameters if needed.

You may want to try using the form's ActiveControl property to see
which control is currently active.
 
Back
Top