Popup event of a menuitem in context menu not fired

I

inho yi

Hi

I have one MenuItem in main menu, who has submenus. I
setted Popup event handler of this menu item in order to
check or uncheck its sub menus. I want to clone this menu
item as one of menu item in my context, which is binded to
a notify icon.

So, I used .CloneMenu()
MenuItem miStatusClone = this.miStatus.CloneMenu();
this.cmTrayIcon.MenuItems.Add(0,miStatusClone);

The problem is, when I click on this menu item in context
menu, Popup event is not fired.

I tried to create another popup event and explicitely set
to this cloned menu item, but no success.

I also tried other events such as Click, but those events
are not fired as well.

Strange problem.. I checked documentation and thought that
there is no reason why the event is not fired...

Can anyone help?
 
M

Max

Are you sure CloneMenu would copy events of the given object as well?
From what you letter it looks like it is not true. The events are not
copied.
You may check it in debugger by viewing miStatusClone.Popup in watch window,
or checking miStatusClone.Popup==null .
I my assumption is correct and the events are not copied you'll need to
attach them manually like
miStatusClone.Popup+=new EventHandler(YourEventHandler);
Where is YourEventHandler is a function you want to be called.
void YourEventHandler(object sender, System.EventArgs e)
{
//Code goes here
}
The same one you would specify in properties window in the designer.
 

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