I
INCA Hellas Ltd
Hello,
I am trying to fill a MenuItem of my MainMenu, with the contents of a
ContextMenu which is on another form.
This is supposed to happen when the second form is shown on a panel of the
first.
Also the MenuItem of the MainMenu (called ModMenu) is removed and added as
needed.
So I wrote the following method, however I am getting an argument exception
when I am adding the MenuItem.
public static bool ShowModMenu(Form1 f1,ContextMenu m)
{
f1.Menu.MenuItems.Add(f1.ModMenu);
Menu.MenuItemCollection f1i=f1.ModMenu.MenuItems;
f1i.Clear();
while (m.MenuItems.Count>0)
{
MenuItem mi=m.MenuItems[0];
m.MenuItems.Remove(mi); // I remove the menuitem from the context menu
because the docs say that a menuitem cannot be in two menus at the same time
f1i.Add(mi); // This throws ArgumentException
}
}
Can anybody point out where the problem is?
Thank you in advance,
Konstantinos Tragas
INCA Hellas Ltd.
I am trying to fill a MenuItem of my MainMenu, with the contents of a
ContextMenu which is on another form.
This is supposed to happen when the second form is shown on a panel of the
first.
Also the MenuItem of the MainMenu (called ModMenu) is removed and added as
needed.
So I wrote the following method, however I am getting an argument exception
when I am adding the MenuItem.
public static bool ShowModMenu(Form1 f1,ContextMenu m)
{
f1.Menu.MenuItems.Add(f1.ModMenu);
Menu.MenuItemCollection f1i=f1.ModMenu.MenuItems;
f1i.Clear();
while (m.MenuItems.Count>0)
{
MenuItem mi=m.MenuItems[0];
m.MenuItems.Remove(mi); // I remove the menuitem from the context menu
because the docs say that a menuitem cannot be in two menus at the same time
f1i.Add(mi); // This throws ArgumentException
}
}
Can anybody point out where the problem is?
Thank you in advance,
Konstantinos Tragas
INCA Hellas Ltd.