Question ContextMenuStrip & MenuStrip

nicorvp

Member
Joined
May 3, 2009
Messages
24
Location
Italy
Programming Experience
5-10
Suppose you have a MenuStrip with a File --> Open menu on a form.
Why if you add the "open" ToolStripMenuItem object to a ContextMenuStrip, it disappears from the MenuStrip?

VB.NET:
Friend WithEvents FileToolStripMenuItem As ToolStripMenuItem
Friend WithEvents Open1ToolStripMenuItem As ToolStripMenuItem
.....
 Me.FileToolStripMenuItem = New ToolStripMenuItem
 Me.Open1ToolStripMenuItem = New ToolStripMenuItem

 Me.FileToolStripMenuItem.DropDownItems.AddRange(New ToolStripItem() {Me.[B][COLOR="red"]Open1ToolStripMenuItem[/COLOR][/B]})
 Me.ContextMenuStrip1.Items.AddRange(New ToolStripItem() {Me.[B][COLOR="Red"]Open1ToolStripMenuItem[/COLOR][/B]})

There is a way to show at the same time the Open1ToolStripMenuItem in the FileMenu and in the contex menu?

Thanks
 
No, there isn't, you have to create two menu items. Easiest and fastest is usually to write them in designer. You can have both items Click event handled by same handler method.
 
Back
Top