ToolBar.Buttons Vlastnost

Definice

Získá kolekci ovládacích ToolBarButton prvků přiřazených k ovládacímu prvku panelu nástrojů.

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

Hodnota vlastnosti

ToolBar.ToolBarButtonCollection

A ToolBar.ToolBarButtonCollection , která obsahuje kolekci ovládacích ToolBarButton prvků.

Příklady

Následující příklad kódu vytvoří a inicializuje ToolBar a tři ToolBarButton ovládací prvky. Tlačítka panelu nástrojů se přiřazují k panelu nástrojů a panel nástrojů se přidá do formuláře. Tento kód vyžaduje, aby Form již byl vytvořen.

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

Poznámky

Vlastnost Buttons je indexovaná kolekce založená na nule, která slouží k uložení všech ToolBarButton ovládacích prvků přiřazených k panelu nástrojů. Vzhledem k tomu, že vlastnost je jen pro čtení, nelze ji přiřadit kolekci tlačítek panelu nástrojů přímo. Tlačítka panelu nástrojů lze přidat nebo odebrat pomocí metod zděděných z ToolBar.ToolBarButtonCollection třídy. Add Pomocí této metody můžete přidat jednotlivá tlačítka a metodu Remove k odstranění tlačítka. Voláním Clear metody odeberte všechna tlačítka z kolekce.

Platí pro

Viz také