Wierd behavor with Context menus

S

Steve Dussinger

I have an application which needs to dynamically create menu items in
a context menu, each time that menu is displayed.

In my program I have a context menu which contains a menuItem called
"moveItemCMI". This menu item needs to have its children repopulated
each time I display the menu. In order to do this, I've written some
code the remove all of the child items from "moveItemCMI" and to
create new menu items containing the correct information each time I
popup this context menu.

The problem is that this only appears to work the first time i display
the menu. On each subsequent attempt to display the context menu, the
"moveItemCMI" menu item has no children (although it does display the
arrow indicating that there are children).

I can see from my debugging output that I am creating the menu items
correctly, but nothing shows up after the first attempt.

Is there something else I need to do to tell the menuItem to refresh
other than simply removing and adding items?

Thanx,
Steve Dussinger
 
M

Mick Doherty

Assign the ContextMenu to a control, instead of Calling the Show Method, and
populate the items in the ContextMenu's Popup Method.

Alternatively, remove the Item from the ContextMenu, repopulate it's child
menuitems and then insert it back into the ContextMenu.
 

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