다음을 통해 공유


ToolBar.ToolBarButtonCollection.Clear 메서드

도구 모음 단추 컬렉션에서 모든 단추를 제거합니다.

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

구문

‘선언
Public Sub Clear
‘사용 방법
Dim instance As ToolBarButtonCollection

instance.Clear
public void Clear ()
public:
virtual void Clear () sealed
public final void Clear ()
public final function Clear ()

설명

Clear 메서드는 컬렉션 전체를 반복하고 ToolBar.ToolBarButtonCollection에 할당된 모든 도구 모음 단추를 제거합니다.

컬렉션에서 개별 도구 모음 단추를 제거하려면 Remove 또는 RemoveAt 메서드를 사용합니다.

컬렉션에 새 ToolBarButton 개체를 추가하려면 Add, AddRange 또는 Insert 메서드를 사용합니다.

예제

다음 코드 예제에서는 Clear 메서드가 호출되기 전후의 ButtonsCount를 보여 줍니다. 이 코드를 실행하려면 먼저 ToolBarButton을 하나 이상 포함하는 ToolBar를 만들어야 합니다.

Public Sub ClearMyToolBar()
    Dim btns As Integer
    ' Get the count before the Clear method is called.
    btns = toolBar1.Buttons.Count
    toolBar1.Buttons.Clear()
    MessageBox.Show("Count Before Clear: " + btns.ToString() & _
        Microsoft.VisualBasic.ControlChars.Cr & "Count After Clear: " & _
        toolBar1.Buttons.Count.ToString())
End Sub
public void ClearMyToolBar()
 {
    int btns;
    // Get the count before the Clear method is called.
    btns = toolBar1.Buttons.Count;
    toolBar1.Buttons.Clear();
    MessageBox.Show("Count Before Clear: " + btns.ToString() +
                    "\nCount After Clear: " + toolBar1.Buttons.Count.ToString());
 }
 
public:
   void ClearMyToolBar()
   {
      int btns;
      // Get the count before the Clear method is called.
      btns = toolBar1->Buttons->Count;
      toolBar1->Buttons->Clear();
      MessageBox::Show( "Count Before Clear: " + btns.ToString() +
         "\nCount After Clear: " + toolBar1->Buttons->Count.ToString() );
   }

플랫폼

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