MenuItem.MergeMenu Method (MenuItem)


Merges another menu item with this menu item.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

member MergeMenu : 
        itemSrc:MenuItem -> unit


Type: System.Windows.Forms.MenuItem

A MenuItem that specifies the menu item to merge with this one.

Menu items are merged according to the value of the menu item's MergeType and MergeOrder properties. This version of the MergeMenu method enables you to merge two MenuItem objects (and their submenus) into a single menu. Menu merging is handled automatically when a Multiple Document Interface (MDI) parent form and a child both have menus. You can use this version of the method to merge two MenuItem objects (and their submenu items) located in a MainMenu control into a single menu within a ContextMenu. For example, you can call this version of the MergeMenu method to merge the menu items of a File and Edit menu into a single MenuItem that can then be added to and displayed by a ContextMenu.

The following code example uses this version of the MergeMenu method to create a copy of a MenuItem and merge it with another. The merged MenuItem is then added to a ContextMenu control. This example requires that there are two menu items called menuItem1 and menuItem2 that contain submenu items within them and a ContextMenu named contextMenu1 to display the menu items. menuItem1 and menuItem2 have different menu items contained within them. After the call to MergeMenu is made, a consolidated menu is created.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 1.1
Return to top