ToolBar.Buttons Eigenschaft

Definition

Ruft die Auflistung von ToolBarButton-Steuerelementen ab, die dem Symbolleisten-Steuerelement zugewiesen sind.

public:
 property System::Windows::Forms::ToolBar::ToolBarButtonCollection ^ Buttons { System::Windows::Forms::ToolBar::ToolBarButtonCollection ^ get(); };
public System.Windows.Forms.ToolBar.ToolBarButtonCollection Buttons { get; }
member this.Buttons : System.Windows.Forms.ToolBar.ToolBarButtonCollection
Public ReadOnly Property Buttons As ToolBar.ToolBarButtonCollection

Eigenschaftswert

ToolBar.ToolBarButtonCollection

Eine ToolBar.ToolBarButtonCollection, die eine Auflistung von ToolBarButton-Steuerelementen enthält.

Beispiele

Im folgenden Codebeispiel wird ein ToolBar und drei ToolBarButton Steuerelemente initialisiert. Die Symbolleistenschaltflächen werden der Symbolleiste zugewiesen, und die Symbolleiste wird dem Formular hinzugefügt. Dieser Code erfordert, dass eine Form bereits erstellt wurde.

public:
   void InitializeMyToolBar()
   {
      // Create and initialize the ToolBarButton controls and ToolBar.
      ToolBar^ toolBar1 = gcnew ToolBar;
      ToolBarButton^ toolBarButton1 = gcnew ToolBarButton;
      ToolBarButton^ toolBarButton2 = gcnew ToolBarButton;
      ToolBarButton^ toolBarButton3 = gcnew ToolBarButton;
      
      // Set the Text properties of the ToolBarButton controls.
      toolBarButton1->Text = "Open";
      toolBarButton2->Text = "Save";
      toolBarButton3->Text = "Print";
      
      // Add the ToolBarButton controls to the ToolBar.
      toolBar1->Buttons->Add( toolBarButton1 );
      toolBar1->Buttons->Add( toolBarButton2 );
      toolBar1->Buttons->Add( toolBarButton3 );
      
      // Add the ToolBar to the Form.
      Controls->Add( toolBar1 );
   }
public void InitializeMyToolBar()
 {
    // Create and initialize the ToolBarButton controls and ToolBar.
    ToolBar toolBar1 = new ToolBar();
    ToolBarButton toolBarButton1 = new ToolBarButton();
    ToolBarButton toolBarButton2 = new ToolBarButton();
    ToolBarButton toolBarButton3 = new ToolBarButton();
 
    // Set the Text properties of the ToolBarButton controls.
    toolBarButton1.Text = "Open";
    toolBarButton2.Text = "Save";
    toolBarButton3.Text = "Print";
 
    // Add the ToolBarButton controls to the ToolBar.
    toolBar1.Buttons.Add(toolBarButton1);
    toolBar1.Buttons.Add(toolBarButton2);
    toolBar1.Buttons.Add(toolBarButton3);
 
    // Add the ToolBar to the Form.
    Controls.Add(toolBar1);
 }
Public Sub InitializeMyToolBar()
    ' Create and initialize the ToolBarButton controls and ToolBar.
    Dim toolBar1 As New ToolBar()
    Dim toolBarButton1 As New ToolBarButton()
    Dim toolBarButton2 As New ToolBarButton()
    Dim toolBarButton3 As New ToolBarButton()
    
    ' Set the Text properties of the ToolBarButton controls.
    toolBarButton1.Text = "Open"
    toolBarButton2.Text = "Save"
    toolBarButton3.Text = "Print"
    
    ' Add the ToolBarButton controls to the ToolBar.
    toolBar1.Buttons.Add(toolBarButton1)
    toolBar1.Buttons.Add(toolBarButton2)
    toolBar1.Buttons.Add(toolBarButton3)
    
    ' Add the ToolBar to the Form.
    Controls.Add(toolBar1)
End Sub

Hinweise

Die Buttons Eigenschaft ist eine nullbasierte indizierte Auflistung, die verwendet wird, um alle Steuerelemente zu halten, die ToolBarButton der Symbolleiste zugewiesen sind. Da die Eigenschaft schreibgeschützt ist, kann es keine Sammlung von Symbolleistenschaltflächen direkt zugewiesen werden. Symbolleistenschaltflächen können mithilfe der von der ToolBar.ToolBarButtonCollection Klasse geerbten Methoden hinzugefügt oder entfernt werden. Verwenden Sie die Methode, um einzelne Schaltflächen und die Add Remove Methode zum Löschen einer Schaltfläche hinzuzufügen. Rufen Sie die Clear Methode auf, um alle Schaltflächen aus der Auflistung zu entfernen.

Gilt für

Siehe auch