ToolStripMenuItem コンストラクタ ()とは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > ToolStripMenuItem コンストラクタ ()の意味・解説 

ToolStripMenuItem コンストラクタ ()


ToolStripMenuItem コンストラクタ (Image)

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

表示される Image指定して、ToolStripMenuItem クラス新しインスタンス初期化します。

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

public ToolStripMenuItem (
    Image image
)
public:
ToolStripMenuItem (
    Image^ image
)
public ToolStripMenuItem (
    Image image
)
public function ToolStripMenuItem (
    image : Image
)

パラメータ

image

コントロール表示される Image

解説解説

テキスト周りマージンイメージ表示する ToolStripMenuItem作成するには、ToolStripMenuItem コンストラクタ使用します

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

ToolStripMenuItem コンストラクタ (String)

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

指定したテキスト表示する ToolStripMenuItem クラス新しインスタンス初期化します。

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Dim text As String

Dim instance As New ToolStripMenuItem(text)
public ToolStripMenuItem (
    string text
)
public:
ToolStripMenuItem (
    String^ text
)
public ToolStripMenuItem (
    String text
)
public function ToolStripMenuItem (
    text : String
)

パラメータ

text

メニュー項目に表示するテキスト

解説解説

名前を指定して 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;
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

ToolStripMenuItem コンストラクタ (String, Image)

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

指定したテキストイメージ表示する ToolStripMenuItem クラス新しインスタンス初期化します。

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

解説解説

名前とイメージ指定して ToolStripMenuItem作成するには、ToolStripMenuItem コンストラクタ使用します

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

ToolStripMenuItem コンストラクタ (String, Image, EventHandler)

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

表示されるテキストイメージ、および、ToolStripMenuItem がクリックされたときに実行されるアクション指定してToolStripMenuItem クラス新しインスタンス初期化します。

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

解説解説

テキストイメージ両方表示し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;
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

ToolStripMenuItem コンストラクタ (String, Image, ToolStripItem[])

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

表示されるテキストイメージ指定して指定した ToolStripItem コレクション格納する ToolStripMenuItem クラス新しインスタンス初期化します。

名前空間: System.Windows.Forms
アセンブリ: 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 ToolStripMenuItem (
    string text,
    Image image,
    params ToolStripItem[] dropDownItems
)
public:
ToolStripMenuItem (
    String^ text, 
    Image^ image, 
    ... array<ToolStripItem^>^ dropDownItems
)
public ToolStripMenuItem (
    String text, 
    Image image, 
    ToolStripItem[] dropDownItems
)
public function ToolStripMenuItem (
    text : String, 
    image : Image, 
    ... dropDownItems : ToolStripItem[]
)

パラメータ

text

メニュー項目に表示するテキスト

image

コントロール表示される Image

dropDownItems

コントロールクリックされたときに表示されるメニュー項目。

解説解説

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

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

ToolStripMenuItem コンストラクタ (String, Image, EventHandler, Keys)

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

表示されるテキストイメージショートカット キー、および、ToolStripMenuItemクリックされたときに実行されるアクション指定してToolStripMenuItem クラス新しインスタンス初期化します。

名前空間: System.Windows.Forms
アセンブリ: 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 ToolStripMenuItem (
    string text,
    Image image,
    EventHandler onClick,
    Keys shortcutKeys
)
public:
ToolStripMenuItem (
    String^ text, 
    Image^ image, 
    EventHandler^ onClick, 
    Keys shortcutKeys
)
public ToolStripMenuItem (
    String text, 
    Image image, 
    EventHandler onClick, 
    Keys shortcutKeys
)
public function ToolStripMenuItem (
    text : String, 
    image : Image, 
    onClick : EventHandler, 
    shortcutKeys : Keys
)

パラメータ

text

メニュー項目に表示するテキスト

image

コントロール表示される Image

onClick

コントロールクリックされたときに Click イベント発生させるイベント ハンドラ

shortcutKeys

ToolStripMenuItem のショートカット キーを表す Keys の値の 1 つ

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

ToolStripMenuItem コンストラクタ (String, Image, EventHandler, String)

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

表示されるテキストイメージ、名前、および、ToolStripMenuItem がクリックされたときに実行されるアクション指定してToolStripMenuItem クラス新しインスタンス初期化します。

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

使用例使用例

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;
    }
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

ToolStripMenuItem コンストラクタ

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 クラス
ToolStripMenuItem メンバ
System.Windows.Forms 名前空間



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「ToolStripMenuItem コンストラクタ ()」の関連用語

ToolStripMenuItem コンストラクタ ()のお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ToolStripMenuItem コンストラクタ ()のページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS