dotnetmonitor.com |
|
||||||||||||
| For the implementation of faux-ambient properties
we make a distinction in how the dropdown for a ToolStripDropDownItem is created.
We automatically flow Font, ImageScalingSize and Renderer to the autocreated
dropdown. In the case of explicitly created dropdowns you must set these properties
yourself.
Explicit creation of ToolStripDropDown Refers to instancing a ToolStripDropDown, ToolStripDropDownMenu or ContextMenuStrip, populating it, then assigning to a ToolStripDropDownItems DropDown property:
Implicit (automatic) creation of ToolStripDropDown Refers to populating a ToolStripDropDownItems DropDownItems collection. When that item is activated, the dropdown in created by use containing the item from the OwnerItems DropDownItems collection.: SampleRun the following sample; it shows the font flows into the veggies menu dropdown, but not fruit. // explicit ContextMenuStrip cms = new ContextMenuStrip(); cms.Items.Add("Apples"); cms.Items.Add("Bananas"); cms.Items.Add("Cherries");
ToolStripMenuItem fruitMenuItem = new ToolStripMenuItem("Fruit"); fruitMenuItem.DropDown = cms;
// implicit (automatic) ToolStripMenuItem veggiesMenuItem = new ToolStripMenuItem("Veggies"); veggiesMenuItem.DropDownItems.Add("Asparagus"); veggiesMenuItem.DropDownItems.Add("Bok Choy"); veggiesMenuItem.DropDownItems.Add("Cauliflower");
// menustrip MenuStrip ms = new MenuStrip(); // set Font to show property flow ms.Font = new Font("Tebuchet MS", 14, FontStyle.Bold); ms.Items.Add(fruitMenuItem); ms.Items.Add(veggiesMenuItem); this.Controls.Add(ms); |
||||||||||||
|
||||||||||||