ToolBar.ToolBarButtonCollection (Clase) (System.Windows.Forms)

Cambiar vista:
Sin script
Biblioteca de clases de .NET Framework
ToolBar.ToolBarButtonCollection (Clase)

Actualización: noviembre 2007

Encapsula una colección de controles ToolBarButton para su uso en la clase ToolBar.

Espacio de nombres:  System.Windows.Forms
Ensamblado:  System.Windows.Forms (en System.Windows.Forms.dll)
Sintaxis

Visual Basic (Declaración)
Public Class ToolBarButtonCollection _
	Implements IList, ICollection, IEnumerable
Visual Basic (Uso)
Dim instance As ToolBar.ToolBarButtonCollection
C#
public class ToolBarButtonCollection : IList, 
	ICollection, IEnumerable
Visual C++
public ref class ToolBarButtonCollection : IList, 
	ICollection, IEnumerable
J#
public class ToolBarButtonCollection implements IList, 
	ICollection, IEnumerable
JScript
public class ToolBarButtonCollection implements IList, ICollection, IEnumerable
Comentarios

ToolBar.ToolBarButtonCollection es una colección indizada de base cero que utiliza la clase ToolBar para mantener asignados todos los controles ToolBarButton a la barra de herramientas. Utilice el método Add para agregar botones individuales, y el método Remove para eliminarlos. Llame al método Clear para quitar todos los botones de la colección.

Ejemplos

En el siguiente ejemplo de código se crean y se inicializan un ToolBar y tres controles ToolBarButton. Los botones de barra de herramientas se asignan a la barra de herramientas y la barra de herramientas se agrega al formulario. Este código requiere que ya se haya creado un Form.

Visual Basic
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



C#
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);
 }



Visual C++
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 );
   }


J#
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.set_Text("Open");
    toolBarButton2.set_Text("Save");
    toolBarButton3.set_Text("Print");

    // Add the ToolBarButton controls to the ToolBar.
    toolBar1.get_Buttons().Add(toolBarButton1);
    toolBar1.get_Buttons().Add(toolBarButton2);
    toolBar1.get_Buttons().Add(toolBarButton3);

    // Add the ToolBar to the Form.
    get_Controls().Add(toolBar1);
} //InitializeMyToolBar


Jerarquía de herencia

System.Object
  System.Windows.Forms.ToolBar.ToolBarButtonCollection
Seguridad para subprocesos

Todos los miembros static (Shared en Visual Basic) públicos de este tipo son seguros para la ejecución de subprocesos. No se garantiza que los miembros de instancias sean seguros para la ejecución de subprocesos.
Plataformas

Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile para Smartphone, Windows Mobile para Pocket PC

.NET Framework y .NET Compact Framework no admiten todas las versiones de cada plataforma. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.
Información de versión

.NET Framework

Compatible con: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Compatible con: 3.5, 2.0, 1.0
Vea también

Referencia