ToolBar.ToolBarButtonCollection.Clear Metoda

Definicja

Usuwa wszystkie przyciski z kolekcji przycisków paska narzędzi.

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

Implementuje

Przykłady

Poniższy przykład kodu wyświetla przed Count Buttons i po wywołaniu Clear metody . Ten kod wymaga, aby ToolBar obiekt z co najmniej jednym ToolBarButton obiektem został utworzony.

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

Uwagi

Metoda Clear wykonuje iterację po kolekcji i usuwa wszystkie przyciski paska narzędzi przypisane do elementu ToolBar.ToolBarButtonCollection.

Aby usunąć pojedynczy przycisk paska narzędzi z kolekcji, użyj Remove metod lub RemoveAt .

Aby dodać nowe ToolBarButton obiekty do kolekcji, użyj Addmetod lub AddRange Insert .

Dotyczy

Zobacz też