ToolStripMenuItem コンストラクタ ()
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)


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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


ToolStripMenuItem コンストラクタ (Image)
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)



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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


ToolStripMenuItem コンストラクタ (String)
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)



ToolStripMenuItem コンストラクタの使用方法を次のコード例に示します。
' 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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


ToolStripMenuItem コンストラクタ (String, Image)
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)



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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


ToolStripMenuItem コンストラクタ (String, Image, EventHandler)
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

Dim text As String Dim image As Image Dim onClick As EventHandler Dim instance As New ToolStripMenuItem(text, image, onClick)

テキストとイメージの両方を表示し、ToolStripMenuItem がクリックされたときに指定したアクションを実行する ToolStripMenuItem を作成するには、ToolStripMenuItem を使用します。

ToolStripMenuItem コンストラクタの使用方法を次のコード例に示します。
' 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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


ToolStripMenuItem コンストラクタ (String, Image, ToolStripItem[])
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

Public Sub New ( _ text As String, _ image As Image, _ ParamArray dropDownItems As ToolStripItem() _ )
Dim text As String Dim image As Image Dim dropDownItems As ToolStripItem() Dim instance As New ToolStripMenuItem(text, image, dropDownItems)
public function ToolStripMenuItem ( text : String, image : Image, ... dropDownItems : ToolStripItem[] )

テキストとイメージを表示し、指定した ToolStripItem コレクションを格納する ToolStripMenuItem を作成するには、ToolStripMenuItem コンストラクタを使用します。

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


ToolStripMenuItem コンストラクタ (String, Image, EventHandler, Keys)
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

Public Sub New ( _ text As String, _ image As Image, _ onClick As EventHandler, _ shortcutKeys As Keys _ )
Dim text As String Dim image As Image Dim onClick As EventHandler Dim shortcutKeys As Keys Dim instance As New ToolStripMenuItem(text, image, onClick, shortcutKeys)
public function ToolStripMenuItem ( text : String, image : Image, onClick : EventHandler, shortcutKeys : Keys )
- shortcutKeys
ToolStripMenuItem のショートカット キーを表す Keys の値の 1 つ。

テキストとイメージを表示し、クリックされたときに指定したアクションを実行し、指定したショートカット キーを持つ ToolStripMenuItem を作成するには、ToolStripMenuItem コンストラクタを使用します。

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


ToolStripMenuItem コンストラクタ (String, Image, EventHandler, String)
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

Public Sub New ( _ text As String, _ image As Image, _ onClick As EventHandler, _ name As String _ )
Dim text As String Dim image As Image Dim onClick As EventHandler Dim name As String Dim instance As New ToolStripMenuItem(text, image, onClick, name)
public function ToolStripMenuItem ( text : String, image : Image, onClick : EventHandler, name : String )

ToolStripMenuItem コンストラクタの使用方法を次のコード例に示します。
' This code example demonstrates how to handle the Opening event. ' It also demonstrates dynamic item addition and dynamic ' SourceControl determination with reuse. Class Form3 Inherits Form ' Declare the ContextMenuStrip control. Private fruitContextMenuStrip As ContextMenuStrip Public Sub New() ' Create a new ContextMenuStrip control. fruitContextMenuStrip = New ContextMenuStrip() ' Attach an event handler for the ' ContextMenuStrip control's Opening event. AddHandler fruitContextMenuStrip.Opening, AddressOf cms_Opening ' Create a new ToolStrip control. Dim ts As New ToolStrip() ' Create a ToolStripDropDownButton control and add it ' to the ToolStrip control's Items collections. Dim fruitToolStripDropDownButton As New ToolStripDropDownButton("Fruit", Nothing, Nothing, "Fruit") ts.Items.Add(fruitToolStripDropDownButton) ' Dock the ToolStrip control to the top of the form. ts.Dock = DockStyle.Top ' Assign the ContextMenuStrip control as the ' ToolStripDropDownButton control's DropDown menu. fruitToolStripDropDownButton.DropDown = fruitContextMenuStrip ' Create a new MenuStrip control and add a ToolStripMenuItem. Dim ms As New MenuStrip() Dim fruitToolStripMenuItem As New ToolStripMenuItem("Fruit", Nothing, Nothing, "Fruit") ms.Items.Add(fruitToolStripMenuItem) ' Dock the MenuStrip control to the top of the form. ms.Dock = DockStyle.Top ' Assign the MenuStrip control as the ' ToolStripMenuItem's DropDown menu. fruitToolStripMenuItem.DropDown = fruitContextMenuStrip ' Assign the ContextMenuStrip to the form's ' ContextMenuStrip property. Me.ContextMenuStrip = fruitContextMenuStrip ' Add the ToolStrip control to the Controls collection. Me.Controls.Add(ts) 'Add a button to the form and assign its ContextMenuStrip. Dim b As New Button() b.Location = New System.Drawing.Point(60, 60) Me.Controls.Add(b) b.ContextMenuStrip = fruitContextMenuStrip ' Add the MenuStrip control last. ' This is important for correct placement in the z-order. Me.Controls.Add(ms) End Sub ' This event handler is invoked when the ContextMenuStrip ' control's Opening event is raised. It demonstrates ' dynamic item addition and dynamic SourceControl ' determination with reuse. Sub cms_Opening(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) ' Acquire references to the owning control and item. Dim c As Control = fruitContextMenuStrip.SourceControl Dim tsi As ToolStripDropDownItem = fruitContextMenuStrip.OwnerItem ' Clear the ContextMenuStrip control's ' Items collection. fruitContextMenuStrip.Items.Clear() ' Check the source control first. If Not (c Is Nothing) Then ' Add custom item (Form) fruitContextMenuStrip.Items.Add(("Source: " + c.GetType().ToString())) ElseIf Not (tsi Is Nothing) Then ' Add custom item (ToolStripDropDownButton or ToolStripMenuItem) fruitContextMenuStrip.Items.Add(("Source: " + tsi.GetType().ToString())) End If ' Populate the ContextMenuStrip control with its default items. fruitContextMenuStrip.Items.Add("-") fruitContextMenuStrip.Items.Add("Apples") fruitContextMenuStrip.Items.Add("Oranges") fruitContextMenuStrip.Items.Add("Pears") ' Set Cancel to false. ' It is optimized to true based on empty entry. e.Cancel = False End Sub End Class
// This code example demonstrates how to handle the Opening event. // It also demonstrates dynamic item addition and dynamic // SourceControl determination with reuse. class Form3 : Form { // Declare the ContextMenuStrip control. private ContextMenuStrip fruitContextMenuStrip; public Form3() { // Create a new ContextMenuStrip control. fruitContextMenuStrip = new ContextMenuStrip(); // Attach an event handler for the // ContextMenuStrip control's Opening event. fruitContextMenuStrip.Opening += new System.ComponentModel.CancelEventHandler(cms_Opening); // Create a new ToolStrip control. ToolStrip ts = new ToolStrip(); // Create a ToolStripDropDownButton control and add it // to the ToolStrip control's Items collections. ToolStripDropDownButton fruitToolStripDropDownButton = new ToolStripDropDownButton("Fruit", null, null, "Fruit"); ts.Items.Add(fruitToolStripDropDownButton); // Dock the ToolStrip control to the top of the form. ts.Dock = DockStyle.Top; // Assign the ContextMenuStrip control as the // ToolStripDropDownButton control's DropDown menu. fruitToolStripDropDownButton.DropDown = fruitContextMenuStrip; // Create a new MenuStrip control and add a ToolStripMenuItem. MenuStrip ms = new MenuStrip(); ToolStripMenuItem fruitToolStripMenuItem = new ToolStripMenuItem("Fruit", null, null, "Fruit"); ms.Items.Add(fruitToolStripMenuItem); // Dock the MenuStrip control to the top of the form. ms.Dock = DockStyle.Top; // Assign the MenuStrip control as the // ToolStripMenuItem's DropDown menu. fruitToolStripMenuItem.DropDown = fruitContextMenuStrip; // Assign the ContextMenuStrip to the form's // ContextMenuStrip property. this.ContextMenuStrip = fruitContextMenuStrip; // Add the ToolStrip control to the Controls collection. this.Controls.Add(ts); //Add a button to the form and assign its ContextMenuStrip. Button b = new Button(); b.Location = new System.Drawing.Point(60, 60); this.Controls.Add(b); b.ContextMenuStrip = fruitContextMenuStrip; // Add the MenuStrip control last. // This is important for correct placement in the z-order. this.Controls.Add(ms); } // This event handler is invoked when the ContextMenuStrip // control's Opening event is raised. It demonstrates // dynamic item addition and dynamic SourceControl // determination with reuse. void cms_Opening(object sender, System.ComponentModel.CancelEventArgs e) { // Acquire references to the owning control and item. Control c = fruitContextMenuStrip.SourceControl as Control; ToolStripDropDownItem tsi = fruitContextMenuStrip.OwnerItem as ToolStripDropDownItem; // Clear the ContextMenuStrip control's Items collection. fruitContextMenuStrip.Items.Clear(); // Check the source control first. if (c != null) { // Add custom item (Form) fruitContextMenuStrip.Items.Add("Source: " + c.GetType().ToString()); } else if (tsi != null) { // Add custom item (ToolStripDropDownButton or ToolStripMenuItem) fruitContextMenuStrip.Items.Add("Source: " + tsi.GetType().ToString()); } // Populate the ContextMenuStrip control with its default items. fruitContextMenuStrip.Items.Add("-"); fruitContextMenuStrip.Items.Add("Apples"); fruitContextMenuStrip.Items.Add("Oranges"); fruitContextMenuStrip.Items.Add("Pears"); // Set Cancel to false. // It is optimized to true based on empty entry. e.Cancel = false; } }

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


ToolStripMenuItem コンストラクタ

名前 | 説明 |
---|---|
ToolStripMenuItem () | ToolStripMenuItem クラスの新しいインスタンスを初期化します。 |
ToolStripMenuItem (Image) | 表示される Image を指定して、ToolStripMenuItem クラスの新しいインスタンスを初期化します。 |
ToolStripMenuItem (String) | 指定したテキストを表示する ToolStripMenuItem クラスの新しいインスタンスを初期化します。 |
ToolStripMenuItem (String, Image) | 指定したテキストとイメージを表示する ToolStripMenuItem クラスの新しいインスタンスを初期化します。 |
ToolStripMenuItem (String, Image, EventHandler) | 表示されるテキストとイメージ、および、ToolStripMenuItem がクリックされたときに実行されるアクションを指定して、ToolStripMenuItem クラスの新しいインスタンスを初期化します。 |
ToolStripMenuItem (String, Image, ToolStripItem[]) | 表示されるテキストとイメージを指定して、指定した ToolStripItem コレクションを格納する ToolStripMenuItem クラスの新しいインスタンスを初期化します。 |
ToolStripMenuItem (String, Image, EventHandler, Keys) | 表示されるテキストとイメージ、ショートカット キー、および、ToolStripMenuItem がクリックされたときに実行されるアクションを指定して、ToolStripMenuItem クラスの新しいインスタンスを初期化します。 |
ToolStripMenuItem (String, Image, EventHandler, String) | 表示されるテキストとイメージ、名前、および、ToolStripMenuItem がクリックされたときに実行されるアクションを指定して、ToolStripMenuItem クラスの新しいインスタンスを初期化します。 |

- ToolStripMenuItem コンストラクタ ()のページへのリンク