다음을 통해 공유


ToolBar.Buttons 속성

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

네임스페이스: System.Windows.Forms
어셈블리: System.Windows.Forms(system.windows.forms.dll)

구문

‘선언
<LocalizableAttribute(True)> _
Public ReadOnly Property Buttons As ToolBarButtonCollection
‘사용 방법
Dim instance As ToolBar
Dim value As ToolBarButtonCollection

value = instance.Buttons
[LocalizableAttribute(true)] 
public ToolBarButtonCollection Buttons { get; }
[LocalizableAttribute(true)] 
public:
property ToolBarButtonCollection^ Buttons {
    ToolBarButtonCollection^ get ();
}
/** @property */
public ToolBarButtonCollection get_Buttons ()
public function get Buttons () : ToolBarButtonCollection

속성 값

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

설명

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

예제

다음 코드 예제에서는 한 개의 ToolBar와 세 개의 ToolBarButton 컨트롤을 만들고 초기화합니다. 도구 모음 단추는 도구 모음에 할당되고 도구 모음은 폼에 추가됩니다. 이 코드를 실행하려면 먼저 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

플랫폼

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

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

.NET Compact Framework

2.0, 1.0에서 지원

참고 항목

참조

ToolBar 클래스
ToolBar 멤버
System.Windows.Forms 네임스페이스
ToolBar.ToolBarButtonCollection