MenuItem_Popup Event Not Firing?

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
 
J

Jay B. Harlow [MVP - Outlook]

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
 
I

Ian Cooper

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
 
I

Ian Cooper

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
 
C

Chris Pels

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.
 

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