![]() This.ContextMenuStrip = fruitContextMenuStrip Assign the ContextMenuStrip to the form's Dock the MenuStrip control to the top of the form.įruitToolStripMenuItem.DropDown = fruitContextMenuStrip ToolStripMenuItem fruitToolStripMenuItem = new ToolStripMenuItem("Fruit", null, null, "Fruit") Create a new MenuStrip control and add a ToolStripMenuItem. ToolStripDropDownButton control's DropDown menu.įruitToolStripDropDownButton.DropDown = fruitContextMenuStrip Assign the ContextMenuStrip control as the Dock the ToolStrip control to the top of the form. Ts.Items.Add(fruitToolStripDropDownButton) ToolStripDropDownButton fruitToolStripDropDownButton = new ToolStripDropDownButton("Fruit", null, null, "Fruit") to the ToolStrip control's Items collections. Create a ToolStripDropDownButton control and add it ![]() ContextMenuStrip control's Opening event.įruitContextMenuStrip.Opening += new (cms_Opening) Create a new ContextMenuStrip control.įruitContextMenuStrip = new ContextMenuStrip() Private ContextMenuStrip fruitContextMenuStrip SourceControl determination with reuse. It also demonstrates dynamic item addition and dynamic This code example demonstrates how to handle the Opening event. The Opening event handler examines the ContextMenuStrip.SourceControl and ToolStripItem.OwnerItem properties and adds a ToolStripItem describing the source control. In the example, an Opening event handler populates the menu item collection. The example also shows how to reuse the same ContextMenuStrip for three different controls on the form. The following code example demonstrates how to dynamically add items to a ContextMenuStrip control. You can dynamically populate the menu item collection of a ToolStrip control when the menu opens.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |