ToolBar.Buttons ToolBar.Buttons ToolBar.Buttons ToolBar.Buttons Property

Definición

Obtiene la colección de controles ToolBarButton asignados al control de la barra de herramientas.Gets the collection of ToolBarButton controls assigned to the toolbar control.

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

Valor de propiedad

Ejemplos

En el ejemplo de código siguiente se crean e ToolBar inicializan ToolBarButton un y tres controles.The following code example creates and initializes a ToolBar and three ToolBarButton controls. Los botones de la barra de herramientas se asignan a la barra de herramientas y la barra de herramientas se agrega al formulario.The toolbar buttons are assigned to the toolbar and the toolbar is added to the form. Este código requiere que ya Form se haya creado un.This code requires that a Form has already been created.

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

Comentarios

La Buttons propiedad es una colección indizada de base cero que se usa para ToolBarButton contener todos los controles asignados a la barra de herramientas.The Buttons property is a zero-based indexed collection used to hold all the ToolBarButton controls assigned to the toolbar. Dado que la propiedad es de solo lectura, no se le puede asignar directamente una colección de botones de barra de herramientas.Because the property is read-only, it can not be assigned a collection of toolbar buttons directly. Los botones de barra de herramientas se pueden agregar o quitar mediante los métodos ToolBar.ToolBarButtonCollection heredados de la clase.Toolbar buttons can be added or removed by using the methods inherited from the ToolBar.ToolBarButtonCollection class. Use el Add método para agregar botones individuales y el Remove método para eliminar un botón.Use the Add method to add individual buttons and the Remove method to delete a button. Llame al Clear método para quitar todos los botones de la colección.Call the Clear method to remove all the buttons from the collection.

Se aplica a

Consulte también: