다음을 통해 공유


ToolBar.ToolBarButtonCollection 클래스

ToolBar 클래스에서 사용할 ToolBarButton 컨트롤의 컬렉션을 캡슐화합니다.

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

구문

‘선언
Public Class ToolBarButtonCollection
    Implements IList, ICollection, IEnumerable
‘사용 방법
Dim instance As 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은 인덱스가 0부터 시작하는 컬렉션으로서 도구 모음에 할당된 모든 ToolBarButton 컨트롤을 저장하기 위해 ToolBar 클래스에서 사용됩니다. 개별 단추를 추가하려면 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

상속 계층 구조

System.Object
  System.Windows.Forms.ToolBar.ToolBarButtonCollection

스레드로부터의 안전성

이 형식의 모든 public static(Visual Basic의 경우 Shared) 멤버는 스레드로부터 안전합니다. 인터페이스 멤버는 스레드로부터 안전하지 않습니다.

플랫폼

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.ToolBarButtonCollection 멤버
System.Windows.Forms 네임스페이스
ToolBar 클래스
ToolBarButton