MenuStrip コンストラクタ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文
解説
使用例
MenuStrip コンストラクタのコード例を次に示します。このコード例は、ToolStripPanel クラスのトピックで取り上げているコード例の一部分です。
' 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
// 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;
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
- MenuStrip コンストラクタのページへのリンク