
References to the System and assemblies. += new System.EventHandler(this.openToolStripMenuItem_Click) Ī MenuStrip control on Form1 named menuStrip1, and a MenuStrip control on Form2 named menuStrip2. Private Sub openToolStripMenuItem_Click(sender As Object, e As _ĮventArgs) Handles openToolStripMenuItem.Click
#VB.NET BIND MENUSTRIP CODE#
Place code similar to the following code example in the &Open ToolStripMenuItem to register the event handler. Set the parent form of the child window. Private void openToolStripMenuItem_Click(object sender, EventArgs e)

'Set the parent form of the child window. Double click on Copy control and write this Code. Add one More control in Main form MenuStrip As Copy under Edit Menu. Assumes there is an MDI parent form having MenuStrip with option New, Window and Close in New menu, main form contain one Child form having a RichTexBox. Private Sub openToolStripMenuItem_Click(ByVal sender As System.Object, _īyVal e As System.EventArgs) Handles openToolStripMenuItem.Click Step to Create and Implement MDI Child Form. Within the event handler, insert code similar to the following code example to create and display new instances of Form2 as MDI children of Form1. Form2 menu itemĬreate an event handler for the Click event of the &Open ToolStripMenuItem. Set the MergeAction and MergeIndex properties of the Form2 menu items as shown in the following table. To insert a MenuStrip into an MDI drop-down menuĬreate a form and set its IsMdiContainer property to true.Īdd a MenuStrip to Form1 and set the AllowMerge property of the MenuStrip to true.Īdd a top-level menu item to the Form1 MenuStrip and set its Text property to &File.Īdd three submenu items to the &File menu item and set their Text properties to &Open, &Import from, and E&xit.Īdd two submenu items to the &Import from submenu item and set their Text properties to &Word and &Excel.Īdd a form to the project, add a MenuStrip to the form, and set the AllowMerge property of the Form2 MenuStrip to true.Īdd a top-level menu item to the Form2 MenuStrip and set its Text property to &File.Īdd submenu items to the &File menu of Form2 in the following order: a ToolStripSeparator, &Save, Save and &Close, and another ToolStripSeparator.

Closing the MDI child window removes the inserted menu items from the MDI parent. The following procedure uses the IsMdiContainer, AllowMerge, MergeAction, and MergeIndex properties to insert a group of menu items from the MDI child menu into the drop-down part of the MDI parent menu.
#VB.NET BIND MENUSTRIP UPDATE#
In that case, you want to update the contents of the MDI parent's menu with the contents of the MDI child's menu as MDI child windows of different kinds are activated. For example, the MDI parent might be a spreadsheet, and the MDI child might be a chart. In some applications, the kind of a multiple-document interface (MDI) child window can be different from the MDI parent window.
