ToolBar.ToolBarButtonCollection.Count Właściwość

Definicja

Pobiera liczbę przycisków w kolekcji przycisków paska narzędzi.

public:
 property int Count { int get(); };
[System.ComponentModel.Browsable(false)]
public int Count { get; }
[<System.ComponentModel.Browsable(false)>]
member this.Count : int
Public ReadOnly Property Count As Integer

Wartość właściwości

Liczba kontrolek przypisanych ToolBarButton do paska narzędzi.

Implementuje

Atrybuty

Przykłady

W poniższym przykładzie kodu jest wyświetlana Count wartość Buttons przed i po wywołaniu Clear metody. Ten kod wymaga utworzenia ToolBar co najmniej jednego ToolBarButton z nich.

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

Właściwość Count zawiera rzeczywistą liczbę kontrolek przypisanych ToolBarButton do kolekcji. Często używa Count się wartości właściwości jako górnej granicy pętli, aby iterować przez kolekcję. Wartość indeksu kolekcji jest indeksem opartym na zera, więc musisz odjąć jedną ze zmiennej pętli, w przeciwnym razie przekroczysz górne granice kolekcji i zgłosisz wyjątek.

Dotyczy

Zobacz też