MenuMerge Wyliczenie

Definicja

Określa zachowanie MenuItem elementu podczas scalania z elementami w innym menu.

public enum class MenuMerge
public enum MenuMerge
type MenuMerge = 
Public Enum MenuMerge
Dziedziczenie
MenuMerge

Pola

Add 0

Element MenuItem jest dodawany do kolekcji istniejących MenuItem obiektów w scalonym menu.

MergeItems 2

Wszystkie elementy podrzędne są MenuItem scalane z istniejącymi MenuItem obiektami w tym samym położeniu w scalanym menu.

Remove 3

Element MenuItem nie jest uwzględniony w scalanym menu.

Replace 1

Element MenuItem zastępuje istniejący MenuItem element w tym samym położeniu w scalanym menu.

Przykłady

W poniższym przykładzie użyto tej wersji MergeMenu metody, aby utworzyć kopię elementu MenuItem i scalić ją z inną. Scalony element jest następnie dodawany MenuItem do kontrolki ContextMenu . W tym przykładzie założono, że istnieją dwa elementy menu o nazwie menuItem1 i menuItem2 zawierające w nich elementy podrzędne oraz ContextMenu nazwane contextMenu1 do wyświetlania elementów menu. menuItem1 w menuItem2 nich znajdują się różne elementy menu. Po nawiązaniu wywołania MergeMenu zostanie utworzone skonsolidowane menu.

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

Uwagi

Użyj elementów członkowskich tego wyliczenia, aby ustawić wartość MergeType właściwości MenuItem.

Dotyczy