+= 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
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. Private Sub openToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles openToolStripMenuItem.Click 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. Set the MergeAction property of the &Special, Command&1, and Command&2 menu items to Append.Ĭreate an event handler for the Click event of the &Open ToolStripMenuItem. Add a top-level menu item to the Form1 MenuStrip and set its Text property to &File. Set the Visible property of the Form1 MenuStrip to false. Add a MenuStrip to Form1 and set the AllowMerge property of the MenuStrip to true.
Set the Visible property of the Form1 MenuStrip to false.Īdd a top-level menu item to the Form1 MenuStrip and set its Text property to &File.Īdd a submenu item to the &File menu item and set its Text property to &Open.Ī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 &Special.Īdd two submenu items to the &Special menu item and set their Text properties to Command&1 and Command&2, respectively. Create a form and set its IsMdiContainer property to true. To append a menu item to an MDI parentĬ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. Closing the MDI child window removes the appended menu from the MDI parent.Īlso see Multiple-Document Interface (MDI) Applications. The following procedure uses the IsMdiContainer, AllowMerge, MergeAction, and MergeIndex properties to append the MDI child menu to the MDI parent menu.
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.