Actualización: noviembre 2007
Encapsula una colección de controles ToolBarButton para su uso en la clase ToolBar.
Ensamblado: System.Windows.Forms (en System.Windows.Forms.dll)
Public Class ToolBarButtonCollection _ Implements IList, ICollection, IEnumerable
Dim instance As ToolBar.ToolBarButtonCollection
public class ToolBarButtonCollection : IList, ICollection, IEnumerable
public ref class ToolBarButtonCollection : IList, ICollection, IEnumerable
public class ToolBarButtonCollection implements IList, ICollection, IEnumerable
public class ToolBarButtonCollection implements IList, ICollection, IEnumerable
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.
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.
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
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: 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.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
System.Windows.Forms.ToolBar.ToolBarButtonCollection
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.