ToolBar.Buttons Özellik

Tanım

Araç çubuğu denetimine atanan denetim koleksiyonunu ToolBarButton alır.

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

Özellik Değeri

ToolBar.ToolBarButtonCollection

Denetim ToolBar.ToolBarButtonCollection koleksiyonu ToolBarButton içeren bir.

Örnekler

Aşağıdaki kod örneği, bir ToolBar ve üç ToolBarButton denetim oluşturur ve başlatır. Araç çubuğu düğmeleri araç çubuğuna atanır ve araç çubuğu forma eklenir. Bu kod için önceden oluşturulmuş bir Form kod gerekir.

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

Açıklamalar

Buttons özelliği, araç çubuğuna atanan tüm ToolBarButton denetimleri tutmak için kullanılan sıfır tabanlı dizinlenmiş bir koleksiyondur. Özelliği salt okunur olduğundan, doğrudan bir araç çubuğu düğmeleri koleksiyonu atanamıyor. Araç çubuğu düğmeleri, sınıfından ToolBar.ToolBarButtonCollection devralınan yöntemler kullanılarak eklenebilir veya kaldırılabilir. Add Tek tek düğmeleri eklemek için yöntemini ve bir düğmeyi Remove silme yöntemini kullanın. Koleksiyonundaki Clear tüm düğmeleri kaldırmak için yöntemini çağırın.

Şunlara uygulanır

Ayrıca bkz.