MenuMerge 枚举

定义

指定 MenuItem 与另一个菜单中的项进行合并时的行为。Specifies the behavior of a MenuItem when it is merged with items in another menu.

public enum class MenuMerge
public enum MenuMerge
type MenuMerge = 
Public Enum MenuMerge
继承
MenuMerge

字段

Add 0

MenuItem 被添加到合并菜单中现有 MenuItem 对象的集合。The MenuItem is added to the collection of existing MenuItem objects in a merged menu.

MergeItems 2

MenuItem 的所有子菜单项与合并菜单中处于相同位置的现有 MenuItem 对象的子菜单项进行合并。All submenu items of this MenuItem are merged with those of existing MenuItem objects at the same position in a merged menu.

Remove 3

MenuItem 不包含在合并菜单中。The MenuItem is not included in a merged menu.

Replace 1

MenuItem 替换合并菜单中相同位置的现有 MenuItemThe MenuItem replaces an existing MenuItem at the same position in a merged menu.

示例

下面的示例使用此版本MergeMenu的方法创建的副本MenuItem , 并将其与另一个合并。The following example uses this version of the MergeMenu method to create a copy of a MenuItem and merge it with another. 合并MenuItem后将添加ContextMenu到控件中。The merged MenuItem is then added to a ContextMenu control. 此示例假设menuItem1有两个名menuItem2为的菜单项, 其中包含其中的子菜单ContextMenu项, contextMenu1名为以显示菜单项。This example assumes 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. menuItem1menuItem2中包含不同的菜单项。menuItem1 and menuItem2 have different menu items contained within them. 调用MergeMenu完成后, 将创建一个合并菜单。After the call to MergeMenu is made, a consolidated menu is created.

private:
   void MergeMyMenus()
   {
      // Set the merge type to merge the items from both top menu items.
      menuItem1->MergeType = MenuMerge::MergeItems;
      menuItem2->MergeType = MenuMerge::MergeItems;
      // Create a copy of my menu item.
      MenuItem^ tempMenuItem = gcnew MenuItem;
      // Create a copy of menuItem1 before doing the merge.
      tempMenuItem = menuItem1->CloneMenu();
      // Merge menuItem1's copy with a clone of menuItem2
      tempMenuItem->MergeMenu( menuItem2->CloneMenu() );
      
      // Add the merged menu to the ContextMenu control.
      contextMenu1->MenuItems->Add( tempMenuItem );
   }
private void MergeMyMenus()
{
   // Set the merge type to merge the items from both top menu items.
   menuItem1.MergeType = MenuMerge.MergeItems;
   menuItem2.MergeType = MenuMerge.MergeItems;
   // Create a copy of my menu item.
   MenuItem tempMenuItem = new MenuItem();
   // Create a copy of menuItem1 before doing the merge.
   tempMenuItem = menuItem1.CloneMenu();
   // Merge menuItem1's copy with a clone of menuItem2
   tempMenuItem.MergeMenu(menuItem2.CloneMenu());

   // Add the merged menu to the ContextMenu control.
   contextMenu1.MenuItems.Add(tempMenuItem);
}

Private Sub MergeMyMenus()
    ' Set the merge type to merge the items from both top menu items.
    menuItem1.MergeType = MenuMerge.MergeItems
    menuItem2.MergeType = MenuMerge.MergeItems
    ' Create a copy of my menu item.
    Dim tempMenuItem As New MenuItem()
    ' Create a copy of menuItem1 before doing the merge.
    tempMenuItem = menuItem1.CloneMenu()
    ' Merge menuItem1's copy with a clone of menuItem2
    tempMenuItem.MergeMenu(menuItem2.CloneMenu())
       
    ' Add the merged menu to the ContextMenu control.
    contextMenu1.MenuItems.Add(tempMenuItem)
End Sub

注解

使用此枚举的成员可设置的MergeType MenuItem属性的值。Use the members of this enumeration to set the value of the MergeType property of the MenuItem.

适用于