MenuItem_Popup Event Not Firing?

  • Thread starter Thread starter Chris Pels
  • Start date Start date
C

Chris Pels

Is there a problem with the MenuItem_Popup event in 1.0? I have an event
handler attached and the code within the handler is never called. Any
insights appreciated.

Thanks,
Chris
 
Chris,
Does that menu item have sub menu items?

The MenuItem Popup event only occurs for menu items that have sub menu
items, so that you can set properties of the sub items. For a sub menu item
itself, the event does not occur.

Hope this helps
Jay
 
this.menuItem2.Popup += new System.EventHandler(this.menuItem2_Popup);
private void menuItemAttributes_Popup(object sender, System.EventArgs e)

This may be a typo, but the name of the method you pass to the event handler subscribed to this.menuItem2.Popup should be the name of the menu popup method. Yours do no match i.e. you should have:
private void menuItem2_Popup(object sender, System.EventArgs e)


Ian Cooper
wwww.dnug.org.uk
 
The Popup event is never called in this simple test form. If someone can
figure out why, revise the form and post it again.
Don't use the MouseUp event. Instead set the ContextMenu property of the control; the popup event fires and then your message box is displayed.
Sorry my newsreader doesn't support attachments, but I have tested this on your code and it works.
Ian Cooper
www.dnug.org.uk
 
Your solution works. FYI, this is on a TreeView control. However, this
causes the content menu to be displayed whenever there is a right click on
the control. I need to have the context menu displayed when the user right
clicks on certain types of nodes in the TreeView. That is why I trapped the
MouseUp event so I can test which node they have clicked on and determine
whether to display the context menu.

Is there a way to cancel the PopuUp event so I could achieve this
functionality?

Thanks,
Chris

Ian Cooper said:
Don't use the MouseUp event. Instead set the ContextMenu property of the
control; the popup event fires and then your message box is displayed.
 
Back
Top