Condividi tramite


MenuMerge Enumerazione

Definizione

Attenzione

Menu is provided for binary compatibility with .NET Framework and is not intended to be used directly from your code. Use ToolStripDropDown and ToolStripDropDownMenu instead.

Specifica il comportamento di un MenuItem quando viene unito alle voci in un altro menu.

public enum class MenuMerge
public enum MenuMerge
[System.ComponentModel.Browsable(false)]
[System.Obsolete("`Menu` is provided for binary compatibility with .NET Framework and is not intended to be used directly from your code. Use `ToolStripDropDown` and `ToolStripDropDownMenu` instead.", false, DiagnosticId="WFDEV006", UrlFormat="https://aka.ms/winforms-warnings/{0}")]
public enum MenuMerge
type MenuMerge = 
[<System.ComponentModel.Browsable(false)>]
[<System.Obsolete("`Menu` is provided for binary compatibility with .NET Framework and is not intended to be used directly from your code. Use `ToolStripDropDown` and `ToolStripDropDownMenu` instead.", false, DiagnosticId="WFDEV006", UrlFormat="https://aka.ms/winforms-warnings/{0}")>]
type MenuMerge = 
Public Enum MenuMerge
Ereditarietà
MenuMerge
Attributi

Campi

Nome Valore Descrizione
Add 0

L'oggetto MenuItem viene aggiunto all'insieme di oggetti esistenti MenuItem in un menu unito.

Replace 1

MenuItem Sostituisce un oggetto esistente MenuItem nella stessa posizione in un menu unito.

MergeItems 2

Tutti gli elementi di sottomenu di questo MenuItem oggetto vengono uniti a quelli degli oggetti esistenti MenuItem nella stessa posizione in un menu unito.

Remove 3

l'oggetto MenuItem non è incluso in un menu unito.

Esempio

Nell'esempio seguente viene utilizzata questa versione del MergeMenu metodo per creare una copia di un MenuItem oggetto e unirla a un'altra. L'oggetto unito MenuItem viene quindi aggiunto a un ContextMenu controllo . In questo esempio si presuppone che siano presenti due voci di menu denominate menuItem1 e menuItem2 che contengano voci di sottomenu all'interno di esse e un ContextMenu oggetto denominato contextMenu1 per visualizzare le voci di menu. menuItem1 e menuItem2 hanno voci di menu diverse contenute all'interno di essi. Dopo aver effettuato la chiamata a MergeMenu , viene creato un menu consolidato.

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

Commenti

Utilizzare i membri di questa enumerazione per impostare il valore della MergeType proprietà dell'oggetto MenuItem.

Si applica a