I have an item in the main menu and I want the subitems of this item to be duplicated in a context menu.
I clone the subitems as it is described in MSDN.
When I do something with a subitem in the main menu nothing happens to the corresponding subitem in the context menu. For example, when I disable a subitem in the main menu the corresponding subitem in the context menu remains enabled.
Should the cloned subitems change? If no, what's the use in cloning menus?
MigrationUser 1 Sunday, May 02, 2004 9:57 AM
cloning will give you a new copy of the menu.
The purpose of cloning is that you get your copy and can change it without altering the original.
HTH
MigrationUser 1 Sunday, May 02, 2004 10:07 PM
Cloning a menu gives the new copy which is idenpendent of each other, what you should do is use the same instance of the menuitem
e.g. if your menuitem is called menuItem1
mainMenu.MenuItems.Add(menuItem1); // // add it to the context menu as well ctxMenu.MenuItems.Add(menuItem1);
Regards Erymuzuan
MigrationUser 1 Monday, May 03, 2004 1:07 AM
thank you guys for a quick response.
the problem is that i cannot have one instance of a menu item in more than one menu.
When menuItem1 is added to the context menu it magically disappears from the main menu (a menu item can have only one parent menu).
It seems like cloning menus is not of much help - you should update both menus individually.
MigrationUser 1 Monday, May 03, 2004 5:14 PM
well then, if you only want the enabled and or visible property to be in sync all the time then may be you can use the bindingcontext prepoerty of the controls
// suppose there is a menu 'menu' having a menu item 'menuItem1'. // merge the menu with a context menu ContextMenu ctxMenu = new ContextMenu(); ctxMenu.MergeMenu(menu);
// change a property of menuItem1 and you'll see it is in sync with the item in the context menu. menuItem1.Enabled = false; // items in both menus are desabled