ToolBar.Buttons Properti
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Mendapatkan kumpulan ToolBarButton kontrol yang ditetapkan ke kontrol bilah alat.
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
Nilai Properti
Yang ToolBar.ToolBarButtonCollection berisi kumpulan ToolBarButton kontrol.
Contoh
Contoh kode berikut membuat dan menginisialisasi kontrol dan ToolBar tiga ToolBarButton . Tombol toolbar ditetapkan ke toolbar dan toolbar ditambahkan ke formulir. Kode ini mengharuskan telah Form dibuat.
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
Keterangan
Properti Buttons adalah koleksi terindeks berbasis nol yang digunakan untuk menahan semua ToolBarButton kontrol yang ditetapkan ke toolbar. Karena properti bersifat baca-saja, properti tidak dapat diberi kumpulan tombol toolbar secara langsung. Tombol toolbar dapat ditambahkan atau dihapus dengan menggunakan metode yang diwarisi dari ToolBar.ToolBarButtonCollection kelas. Add Gunakan metode untuk menambahkan tombol individual dan Remove metode untuk menghapus tombol. Clear Panggil metode untuk menghapus semua tombol dari koleksi.