Can I share menu items between menus?
- From: "Jeff Johnson" <i.get@xxxxxxxxxxx>
- Date: Thu, 18 Jan 2007 15:25:35 -0500
[VS 2005/Framework 2.0]
I have some menu items (ToolStripMenuItem) that I want displayed in multiple
ways. For example, I have three ways of creating a new document: New From
Existing, New From Template, and New From Scratch. I want to display these
three menu items in three different [sub]menus: File | New, a
ToolStripSplitButton, and a ContextMenuStrip. I originally created two
different sets of items for File | New and the button, but when I got around
to the context menu I decided to try to re-use the menu items from the
button by doing this in my form initialization code:
myContextMenuStrip.Items.AddRange(
new System.Windows.Forms.ToolStripItem[] {
newJobFromTemplateToolStripMenuItem,
newJobFromExistingJobToolStripMenuItem,
newJobFromScratchToolStripMenuItem});
However, while the context menu displays just fine, my toolbar button now
appears to be empty! That is, when you click the dropdown arrow nothing
happens. If I comment out the line above then the dropdown contains the menu
items. This leads me to believe that I have not shared the menu items but
rather moved them. Is there any way to share?
.
- Prev by Date: Re: DataGrid Hierarchical Data view display in Windows Form
- Next by Date: Re: AutoComplete ComboBox with DroppedDown=true
- Previous by thread: Winforms binding -> non-IListSource to a ListBox
- Next by thread: Charts Control
- Index(es):