MenuStrip Constructor
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Initializes a new instance of the MenuStrip class.
public:
MenuStrip();
public MenuStrip ();
Public Sub New ()
Examples
The following code example demonstrates the MenuStrip constructor. This example is part of a larger example provided for the ToolStripPanel class.
// 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
Remarks
Use this constructor to create a MenuStrip to which you can add ToolStripMenuItem objects.
Applies to
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET