ToolBar.ToolBarButtonCollection.Clear 메서드

정의

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

public:
 virtual void Clear();
public void Clear ();
abstract member Clear : unit -> unit
override this.Clear : unit -> unit
Public Sub Clear ()

구현

예제

다음 코드 예제에서는 메서드가 Count 호출되기 Buttons 전과 후 Clear 의 값을 표시합니다. 이 코드를 사용하려면 하나 ToolBarButton 이상의 코드가 생성되어야 합니다ToolBar.

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());
 }
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

설명

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

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

To add new ToolBarButton objects to the collection, use the Add, AddRange or Insert methods.

적용 대상

추가 정보