Hey,

I have a context menu which is being built dynamically.
The menu has regular items and group items which contain sub menu
items.

I didn't want to create the menu all at once, so I decided I will
create the sub menus on the popup event of the parent menu item.

The trouble is that the event handler that I registered on popup is
never called (I did add a dummy menu item, so the popup SHOULD fire).
I tried registering the select event and that 1 works.

Any1 has a clue?!

MenuItem GroupMenuItem = new MenuItem(FolderName); //create group menu
for folder

GroupMenuItem.MenuItems.Add(""); //add dummy menu item so it will
display as a group and raise the Popup event

GroupMenuItem.Popup += new EventHandler(GroupMenuItem_Popup); //assign
popup event handler

DynamicMenu.MenuItems.Add(GroupMenuItem); //add new group menu

when i select the groupmenuitem, the function GroupMenuItem_Popup is
never called, altough i checked in debug and onPopup has this
function...

RE: MenuItem popup event by SoorajPM

SoorajPM
Sun Oct 17 02:15:08 CDT 2004

Hi

Try like this:

MenuItem GroupMenuItem = new MenuItem(FolderName,new
EventHandler(GroupMenuItem_Popup));
DynamicMenu.MenuItems.Add(GroupMenuItem);

Regards
Sooraj
Microsoft Community Star

"xen0x" wrote:

> Hey,
>
> I have a context menu which is being built dynamically.
> The menu has regular items and group items which contain sub menu
> items.
>
> I didn't want to create the menu all at once, so I decided I will
> create the sub menus on the popup event of the parent menu item.
>
> The trouble is that the event handler that I registered on popup is
> never called (I did add a dummy menu item, so the popup SHOULD fire).
> I tried registering the select event and that 1 works.
>
> Any1 has a clue?!
>
> MenuItem GroupMenuItem = new MenuItem(FolderName); //create group menu
> for folder
>
> GroupMenuItem.MenuItems.Add(""); //add dummy menu item so it will
> display as a group and raise the Popup event
>
> GroupMenuItem.Popup += new EventHandler(GroupMenuItem_Popup); //assign
> popup event handler
>
> DynamicMenu.MenuItems.Add(GroupMenuItem); //add new group menu
>
> when i select the groupmenuitem, the function GroupMenuItem_Popup is
> never called, altough i checked in debug and onPopup has this
> function...
>