ToolBarButton ToolBarButton ToolBarButton ToolBarButton Constructors

定義

オーバーロード

ToolBarButton() ToolBarButton() ToolBarButton()

ToolBarButton クラスの新しいインスタンスを初期化します。Initializes a new instance of the ToolBarButton class.

ToolBarButton(String) ToolBarButton(String) ToolBarButton(String) ToolBarButton(String)

ToolBarButton クラスの新しいインスタンスを初期化し、割り当てられたテキストをボタン上に表示します。Initializes a new instance of the ToolBarButton class and displays the assigned text on the button.

ToolBarButton() ToolBarButton() ToolBarButton()

ToolBarButton クラスの新しいインスタンスを初期化します。Initializes a new instance of the ToolBarButton class.

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

次のコード例ではToolBar 、3 ToolBarButtonつのコントロールを作成し、そのボタンをツールバーに割り当てて、ボタンの共通プロパティをいくつか設定します。The following code example creates a ToolBar and three ToolBarButton controls, assigns the buttons to the toolbar, and sets some of the buttons' common properties. このコードMenuItemではImageList ImageList 、、、 Form Imageおよびが作成され、に少なくとも1つのが割り当てられている必要があります。 ToolTipThis code requires that a MenuItem, ImageList, ToolTip and a Form have been created and the ImageList has at least one Image assigned to it.

public:
   void InitializeMyToolBar()
   {
      // Create the ToolBar, ToolBarButton controls, and menus.
      ToolBarButton^ toolBarButton1 = gcnew ToolBarButton( "Open" );
      ToolBarButton^ toolBarButton2 = gcnew ToolBarButton;
      ToolBarButton^ toolBarButton3 = gcnew ToolBarButton;
      ToolBar^ toolBar1 = gcnew ToolBar;
      MenuItem^ menuItem1 = gcnew MenuItem( "Print" );
      array<MenuItem^>^ temp1 = {menuItem1};
      System::Windows::Forms::ContextMenu^ contextMenu1 =
         gcnew System::Windows::Forms::ContextMenu( temp1 );
      
      // Add the ToolBarButton controls to the ToolBar.
      toolBar1->Buttons->Add( toolBarButton1 );
      toolBar1->Buttons->Add( toolBarButton2 );
      toolBar1->Buttons->Add( toolBarButton3 );
      
      // Assign an ImageList to the ToolBar and show ToolTips.
      toolBar1->ImageList = imageList1;
      toolBar1->ShowToolTips = true;
      
      /* Assign ImageIndex, ContextMenu, Text, ToolTip, and 
         Style properties of the ToolBarButton controls. */
      toolBarButton2->Style = ToolBarButtonStyle::Separator;
      toolBarButton3->Text = "Print";
      toolBarButton3->Style = ToolBarButtonStyle::DropDownButton;
      toolBarButton3->ToolTipText = "Print";
      toolBarButton3->ImageIndex = 0;
      toolBarButton3->DropDownMenu = contextMenu1;
      
      // Add the ToolBar to a form.
      Controls->Add( toolBar1 );
   }
public void InitializeMyToolBar()
 {
    // Create the ToolBar, ToolBarButton controls, and menus.
    ToolBarButton toolBarButton1 = new ToolBarButton("Open");
    ToolBarButton toolBarButton2 = new ToolBarButton();
    ToolBarButton toolBarButton3 = new ToolBarButton();
    ToolBar toolBar1 = new ToolBar();
    MenuItem menuItem1 = new MenuItem("Print");
    ContextMenu contextMenu1 = new ContextMenu(new MenuItem[]{menuItem1});

     
    // Add the ToolBarButton controls to the ToolBar.
    toolBar1.Buttons.Add(toolBarButton1);
    toolBar1.Buttons.Add(toolBarButton2);
    toolBar1.Buttons.Add(toolBarButton3);
 
    // Assign an ImageList to the ToolBar and show ToolTips.
    toolBar1.ImageList = imageList1;
    toolBar1.ShowToolTips = true;
 
    /* Assign ImageIndex, ContextMenu, Text, ToolTip, and 
       Style properties of the ToolBarButton controls. */
    toolBarButton2.Style = ToolBarButtonStyle.Separator;
    toolBarButton3.Text = "Print";
    toolBarButton3.Style = ToolBarButtonStyle.DropDownButton;
    toolBarButton3.ToolTipText = "Print";
    toolBarButton3.ImageIndex = 0;
    toolBarButton3.DropDownMenu = contextMenu1;
 
    // Add the ToolBar to a form.
    Controls.Add(toolBar1);
 }
 
   Public Sub InitializeMyToolBar()
       ' Create the ToolBar, ToolBarButton controls, and menus.
       Dim toolBarButton1 As New ToolBarButton("Open")
       Dim toolBarButton2 As New ToolBarButton()
       Dim toolBarButton3 As New ToolBarButton()
       Dim toolBar1 As New ToolBar()
Dim menuItem1 As New MenuItem("Print")
Dim contextMenu1 As New ContextMenu(New MenuItem(){menuItem1})
       
       ' Add the ToolBarButton controls to the ToolBar.
       toolBar1.Buttons.Add(toolBarButton1)
       toolBar1.Buttons.Add(toolBarButton2)
       toolBar1.Buttons.Add(toolBarButton3)
       
       ' Assign an ImageList to the ToolBar and show ToolTips.
       toolBar1.ImageList = imageList1
       toolBar1.ShowToolTips = True
       
       ' Assign ImageIndex, ContextMenu, Text, ToolTip, and
       ' Style properties of the ToolBarButton controls. 
       toolBarButton2.Style = ToolBarButtonStyle.Separator
       toolBarButton3.Text = "Print"
       toolBarButton3.Style = ToolBarButtonStyle.DropDownButton
       toolBarButton3.ToolTipText = "Print"
       toolBarButton3.ImageIndex = 0
       toolBarButton3.DropDownMenu = contextMenu1
       
       ' Add the ToolBar to a form.
       Controls.Add(toolBar1)
   End Sub

注釈

新しく作成さToolBarButtonれたにTextImage既定値がないか、または割り当てられていません。A newly created ToolBarButton has no default Text or Image assigned to it. ボタンの既定のスタイルはToolBarButtonStyle.PushButtonです。The button's default style is ToolBarButtonStyle.PushButton.

こちらもご覧ください

ToolBarButton(String) ToolBarButton(String) ToolBarButton(String) ToolBarButton(String)

ToolBarButton クラスの新しいインスタンスを初期化し、割り当てられたテキストをボタン上に表示します。Initializes a new instance of the ToolBarButton class and displays the assigned text on the button.

public:
 ToolBarButton(System::String ^ text);
public ToolBarButton (string text);
new System.Windows.Forms.ToolBarButton : string -> System.Windows.Forms.ToolBarButton
Public Sub New (text As String)

パラメーター

text
String String String String

新しい ToolBarButton に表示されるテキスト。The text to display on the new ToolBarButton.

次のコード例ではToolBar 、3 ToolBarButtonつのコントロールを作成し、そのボタンをツールバーに割り当てて、ボタンの共通プロパティをいくつか設定します。The following code example creates a ToolBar and three ToolBarButton controls, assigns the buttons to the toolbar, and sets some of the buttons' common properties. このコードMenuItemではImageList ImageList 、、、 Form Imageおよびが作成され、に少なくとも1つのが割り当てられている必要があります。 ToolTipThis code requires that a MenuItem, ImageList, ToolTip and a Form have been created and the ImageList has at least one Image assigned to it.

public:
   void InitializeMyToolBar()
   {
      // Create the ToolBar, ToolBarButton controls, and menus.
      ToolBarButton^ toolBarButton1 = gcnew ToolBarButton( "Open" );
      ToolBarButton^ toolBarButton2 = gcnew ToolBarButton;
      ToolBarButton^ toolBarButton3 = gcnew ToolBarButton;
      ToolBar^ toolBar1 = gcnew ToolBar;
      MenuItem^ menuItem1 = gcnew MenuItem( "Print" );
      array<MenuItem^>^ temp1 = {menuItem1};
      System::Windows::Forms::ContextMenu^ contextMenu1 =
         gcnew System::Windows::Forms::ContextMenu( temp1 );
      
      // Add the ToolBarButton controls to the ToolBar.
      toolBar1->Buttons->Add( toolBarButton1 );
      toolBar1->Buttons->Add( toolBarButton2 );
      toolBar1->Buttons->Add( toolBarButton3 );
      
      // Assign an ImageList to the ToolBar and show ToolTips.
      toolBar1->ImageList = imageList1;
      toolBar1->ShowToolTips = true;
      
      /* Assign ImageIndex, ContextMenu, Text, ToolTip, and 
         Style properties of the ToolBarButton controls. */
      toolBarButton2->Style = ToolBarButtonStyle::Separator;
      toolBarButton3->Text = "Print";
      toolBarButton3->Style = ToolBarButtonStyle::DropDownButton;
      toolBarButton3->ToolTipText = "Print";
      toolBarButton3->ImageIndex = 0;
      toolBarButton3->DropDownMenu = contextMenu1;
      
      // Add the ToolBar to a form.
      Controls->Add( toolBar1 );
   }
public void InitializeMyToolBar()
 {
    // Create the ToolBar, ToolBarButton controls, and menus.
    ToolBarButton toolBarButton1 = new ToolBarButton("Open");
    ToolBarButton toolBarButton2 = new ToolBarButton();
    ToolBarButton toolBarButton3 = new ToolBarButton();
    ToolBar toolBar1 = new ToolBar();
    MenuItem menuItem1 = new MenuItem("Print");
    ContextMenu contextMenu1 = new ContextMenu(new MenuItem[]{menuItem1});

     
    // Add the ToolBarButton controls to the ToolBar.
    toolBar1.Buttons.Add(toolBarButton1);
    toolBar1.Buttons.Add(toolBarButton2);
    toolBar1.Buttons.Add(toolBarButton3);
 
    // Assign an ImageList to the ToolBar and show ToolTips.
    toolBar1.ImageList = imageList1;
    toolBar1.ShowToolTips = true;
 
    /* Assign ImageIndex, ContextMenu, Text, ToolTip, and 
       Style properties of the ToolBarButton controls. */
    toolBarButton2.Style = ToolBarButtonStyle.Separator;
    toolBarButton3.Text = "Print";
    toolBarButton3.Style = ToolBarButtonStyle.DropDownButton;
    toolBarButton3.ToolTipText = "Print";
    toolBarButton3.ImageIndex = 0;
    toolBarButton3.DropDownMenu = contextMenu1;
 
    // Add the ToolBar to a form.
    Controls.Add(toolBar1);
 }
 
   Public Sub InitializeMyToolBar()
       ' Create the ToolBar, ToolBarButton controls, and menus.
       Dim toolBarButton1 As New ToolBarButton("Open")
       Dim toolBarButton2 As New ToolBarButton()
       Dim toolBarButton3 As New ToolBarButton()
       Dim toolBar1 As New ToolBar()
Dim menuItem1 As New MenuItem("Print")
Dim contextMenu1 As New ContextMenu(New MenuItem(){menuItem1})
       
       ' Add the ToolBarButton controls to the ToolBar.
       toolBar1.Buttons.Add(toolBarButton1)
       toolBar1.Buttons.Add(toolBarButton2)
       toolBar1.Buttons.Add(toolBarButton3)
       
       ' Assign an ImageList to the ToolBar and show ToolTips.
       toolBar1.ImageList = imageList1
       toolBar1.ShowToolTips = True
       
       ' Assign ImageIndex, ContextMenu, Text, ToolTip, and
       ' Style properties of the ToolBarButton controls. 
       toolBarButton2.Style = ToolBarButtonStyle.Separator
       toolBarButton3.Text = "Print"
       toolBarButton3.Style = ToolBarButtonStyle.DropDownButton
       toolBarButton3.ToolTipText = "Print"
       toolBarButton3.ImageIndex = 0
       toolBarButton3.DropDownMenu = contextMenu1
       
       ' Add the ToolBar to a form.
       Controls.Add(toolBar1)
   End Sub

注釈

新しく作成さToolBarButtonれたImageは、割り当てられていません。The newly created ToolBarButton has no Image assigned to it. ボタンの既定のスタイルはPushButtonです。The button's default style is PushButton. パラメーターはTextプロパティに割り当てられ、新しいツールバーボタンコントロールに表示されます。 textThe text parameter is assigned to the Text property and is displayed on the new toolbar button control.

こちらもご覧ください

適用対象