How to: Insert a MenuStrip into an MDI Drop-Down Menu (Windows Forms)
In some applications, the kind of a multiple-document interface (MDI) child window can be different from the MDI parent window. For example, the MDI parent might be a spreadsheet, and the MDI child might be a chart. 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.
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. Closing the MDI child window removes the inserted menu items from the MDI parent.
Create a form and set its IsMdiContainer property to
Add three submenu items to the
&Filemenu item and set their Text properties to
&Import from, and
Add two submenu items to the
&Import fromsubmenu item and set their Text properties to
Form2 menu item MergeAction value MergeIndex value File MatchOnly -1 Separator Insert 2 Save Insert 3 Save and Close Insert 4 Separator Insert 5
Within the event handler, insert code similar to the following code example to create and display new instances of
Form2as MDI children of
Place code similar to the following code example in the
&OpenToolStripMenuItem to register the event handler.
This example requires:
Two Form controls named