build context menu from menu strip

P

parez

Hi,

I build the menu strip using the designer.I want the context menu of
the form to be same as the of children of one of the top leven Menu
strip item.


Items["actionToolStripMenuItem"] gives me a ToolStripItem object but
it does not have a hierarchy, no parents no children.

How do i do this in c#?

I tried

this.ContextMenuStrip.Items.AddRange(Menu.Items.Find("actionToolStripMenuItem",true));

but that line removes it from the menustrip and adds it to context
menu



TIA
 
N

Nicholas Paldino [.NET/C# MVP]

parez,

Well, you can always create a new instance of the menu item, and then
add it to the context menu. Also, the menu item should have an Items
property which represents the children menu items on a sub menu.
 
P

parez

parez,

Well, you can always create a new instance of the menu item, and then
add it to the context menu. Also, the menu item should have an Items
property which represents the children menu items on a sub menu.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


I build the menu strip using the designer.I want the context menu of
the form to be same as the of children of one of the top leven Menu
strip item.
Items["actionToolStripMenuItem"] gives me a ToolStripItem object but
it does not have a hierarchy, no parents no children.
How do i do this in c#?
I tried

but that line removes it from the menustrip and adds it to context
menu


ToolStripItem actionItem = Menu.Items["actionToolStripMenuItem"];

actionItem does not have Items property.
 

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