--- title: Merging Menu Items in MenuStrip Control ms.date: "03/30/2017" helpviewer_keywords: - "MenuStrip [Windows Forms], merging" - "merging [Windows Forms], general concepts" ms.assetid: 95e113ba-f362-4dda-8a76-6d95ddc45cee --- # Merging Menu Items in the Windows Forms MenuStrip Control If you have a multiple-document interface (MDI) application, you can merge menu items or whole menus from the child form into the menus of the parent form. This topic describes the basic concepts associated with merging menu items in an MDI application. ## General Concepts Merging procedures involve both a target and a source control: - The target is the control on the main or MDI parent form into which you are merging menu items. - The source is the control on the MDI child form that contains the menu items you want to merge into the target menu. The property identifies the menu item whose drop-down list you will populate with the titles of the current MDI parent form's MDI children. For example, you typically list MDI children that are currently open on the **Window** menu. The property identifies which menu items come from a on an MDI child form. You can merge menu items manually or automatically. The menu items merge in the same way for both methods, but the merge is activated differently, as discussed in the "Manual Merging" and "Automatic Merging" sections later in this topic. In both manual and automatic merging, each merge action affects the next merge action. merging moves menu items from one to another rather than cloning them, as was the case with . ## MergeAction Values You set the merge action on menu items in the source using the property. The following table describes the meaning and typical use of the available merge actions. |MergeAction Value|Description|Typical Use| |-----------------------|-----------------|-----------------| ||(Default) Adds the source item to the end of the target item's collection.|Adding menu items to the end of the menu when some part of the program is activated.| ||Adds the source item to the target item's collection, in the location specified by the property set on the source item.|Adding menu items to the middle or the beginning of the menu when some part of the program is activated.

If the value of is the same for both menu items, they are added in reverse order. Set appropriately to preserve the original order.| ||Finds a text match, or uses the value if no text match is found, and then replaces the matching target menu item with the source menu item.|Replacing a target menu item with a source menu item of the same name that does something different.| ||Finds a text match, or uses the value if no text match is found, and then adds all the drop-down items from the source to the target.|Building a menu structure that inserts or adds menu items into a submenu, or removes menu items from a submenu. For example, you can add a menu item from an MDI child to a main **Save As** menu.

allows you to navigate through the menu structure without taking any action. It provides a way to evaluate the subsequent items.| ||Finds a text match, or uses the value if no text match is found, and then removes the item from the target.|Removing a menu item from the target .| ## Manual Merging Only controls participate in automatic merging. To combine the items of other controls, such as and controls, you must merge them manually, by calling the and methods in your code as required. ## Automatic Merging You can use automatic merging for MDI applications by activating the source form. To use a in an MDI application, set the property to the target so that merging actions performed on the source are reflected in the target . You can trigger automatic merging by activating the on the MDI source. Upon activation, the source is merged into the MDI target. When a new form becomes active, the merge is reverted on the last form and triggered on the new form. You can control this behavior by setting the property as needed on each , and by setting the property on each . ## See also - - - [MenuStrip Control](menustrip-control-windows-forms.md) - [How to: Create an MDI Window List with MenuStrip](how-to-create-an-mdi-window-list-with-menustrip-windows-forms.md) - [How to: Set Up Automatic Menu Merging for MDI Applications](how-to-set-up-automatic-menu-merging-for-mdi-applications.md)