ToolBar.Buttons 속성

정의

ToolBar 컨트롤에 할당된 ToolBarButton 컨트롤의 컬렉션을 가져옵니다.

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

속성 값

ToolBar.ToolBarButtonCollection

ToolBar.ToolBarButtonCollection 컨트롤의 컬렉션을 포함하는 ToolBarButton입니다.

예제

다음 코드 예제에서는 한 개와 세 ToolBarButton 개의 컨트롤을 ToolBar 만들고 초기화합니다. 도구 모음 단추가 도구 모음에 할당되고 도구 모음이 양식에 추가됩니다. 이 코드를 사용하려면 이미 만든 코드가 필요합니다 Form .

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

설명

Buttons 속성은 도구 모음에 할당된 모든 ToolBarButton 컨트롤을 보유하는 데 사용되는 인덱싱된 0부터 시작하는 컬렉션입니다. 이 속성은 읽기 전용이므로 도구 모음 단추 컬렉션을 직접 할당할 수 없습니다. 클래스에서 ToolBar.ToolBarButtonCollection 상속된 메서드를 사용하여 도구 모음 단추를 추가하거나 제거할 수 있습니다. 메서드를 Add 사용하여 개별 단추를 추가하고 단추를 Remove 삭제하는 메서드를 사용합니다. 메서드를 Clear 호출하여 컬렉션에서 모든 단추를 제거합니다.

적용 대상

추가 정보