MenuStrip Costruttore

Definizione

Inizializza una nuova istanza della classe MenuStrip.

public:
 MenuStrip();
public MenuStrip ();
Public Sub New ()

Esempio

Nell'esempio di codice seguente viene illustrato il MenuStrip costruttore. Questo esempio fa parte di un esempio più grande fornito per la ToolStripPanel classe.

// Create a MenuStrip control with a new window.
MenuStrip ms = new MenuStrip();
ToolStripMenuItem windowMenu = new ToolStripMenuItem("Window");
ToolStripMenuItem windowNewMenu = new ToolStripMenuItem("New", null, new EventHandler(windowNewMenu_Click));
windowMenu.DropDownItems.Add(windowNewMenu);
((ToolStripDropDownMenu)(windowMenu.DropDown)).ShowImageMargin = false;
((ToolStripDropDownMenu)(windowMenu.DropDown)).ShowCheckMargin = true;

// Assign the ToolStripMenuItem that displays 
// the list of child forms.
ms.MdiWindowListItem = windowMenu;

// Add the window ToolStripMenuItem to the MenuStrip.
ms.Items.Add(windowMenu);

// Dock the MenuStrip to the top of the form.
ms.Dock = DockStyle.Top;

// The Form.MainMenuStrip property determines the merge target.
this.MainMenuStrip = ms;
' Create a MenuStrip control with a new window.
Dim ms As New MenuStrip()
Dim windowMenu As New ToolStripMenuItem("Window")
Dim windowNewMenu As New ToolStripMenuItem("New", Nothing, New EventHandler(AddressOf windowNewMenu_Click))
windowMenu.DropDownItems.Add(windowNewMenu)
CType(windowMenu.DropDown, ToolStripDropDownMenu).ShowImageMargin = False
CType(windowMenu.DropDown, ToolStripDropDownMenu).ShowCheckMargin = True

' Assign the ToolStripMenuItem that displays 
' the list of child forms.
ms.MdiWindowListItem = windowMenu

' Add the window ToolStripMenuItem to the MenuStrip.
ms.Items.Add(windowMenu)

' Dock the MenuStrip to the top of the form.
ms.Dock = DockStyle.Top

' The Form.MainMenuStrip property determines the merge target.
Me.MainMenuStrip = ms

Commenti

Usare questo costruttore per creare un MenuStrip oggetto a cui è possibile aggiungere ToolStripMenuItem oggetti.

Si applica a