ToolBar.Buttons Eigenschap
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Hiermee haalt u de verzameling ToolBarButton besturingselementen op die zijn toegewezen aan het werkbalkbesturingselement.
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
Waarde van eigenschap
Een ToolBar.ToolBarButtonCollection met een verzameling ToolBarButton besturingselementen.
Voorbeelden
In het volgende codevoorbeeld worden een ToolBar en drie ToolBarButton besturingselementen gemaakt en geïnitialiseerd. De werkbalkknoppen worden toegewezen aan de werkbalk en de werkbalk wordt toegevoegd aan het formulier. Deze code vereist dat er al een Form is gemaakt.
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
Opmerkingen
De Buttons eigenschap is een op nul gebaseerde geïndexeerde verzameling die wordt gebruikt voor het ToolBarButton opslaan van alle besturingselementen die aan de werkbalk zijn toegewezen. Omdat de eigenschap het kenmerk Alleen-lezen heeft, kan er niet rechtstreeks een verzameling werkbalkknoppen aan worden toegewezen. Werkbalkknoppen kunnen worden toegevoegd of verwijderd met behulp van de methoden die zijn overgenomen van de ToolBar.ToolBarButtonCollection klasse. Gebruik de Add methode om afzonderlijke knoppen en de Remove methode toe te voegen om een knop te verwijderen. Roep de Clear methode aan om alle knoppen uit de verzameling te verwijderen.