winforms - C# = MenuItem.Click handler - Get the object the context menu belongs to? -


this might incredibly simple , i'm not seeing because it's end of long day, , if apologize in advance.

i've got set of buttons when right-clicked pop contextmenu. menu has 2 menuitems, both of have click handler function assigned. i'm triggering contextmenu pop on right click of button so:

overly simplified example:

 public void initiailizebuttoncontextmenu() {     buttoncontextmenu = new contextmenu();     menuitem foo = new menuitem("foo");     foo.click += onfooclicked;      menuitemcollection collection = new menuitemcollection(buttoncontextmenu);     collection.add(foo); }  public void onbuttonmouseclick(object sender, mouseeventargs e) {     if (e.button == mousebuttons.left)         // left click stuff handling     if (e.button == mousebuttons.right)         buttoncontextmenu.show((button)sender, new point(e.x, e.y)); }   public void onfooclicked(object sender, eventargs e) {     // need button contextmenu .show'd on in     // onbuttonmouseclick...  thoughts? }   contextmenu buttoncontextmenu;  

i need able button triggered contextmenu pop in click handler menuitem, or it somehow. menuitem.click takes eventargs, nothing useful there. can cast object sender menuitem can't find tells me made pop up. possible?

use contextmenu.sourcecontrol property, gives reference button instance back.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -