ToolBar.ToolBarButtonCollection.Count Propiedad

Definición

Obtiene el número de botones de la colección de botones de barra de herramientas.

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

Valor de propiedad

Número de controles ToolBarButton asignados a la barra de herramientas.

Implementaciones

Atributos

Ejemplos

En el ejemplo de código siguiente se muestra el Count de antes Buttons y después de llamar al Clear método . Este código requiere que se haya creado un ToolBar objeto con al menos uno ToolBarButton .

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

Comentarios

La Count propiedad contiene el número real de ToolBarButton controles asignados a la colección. Es habitual usar el valor de propiedad Count como límites superiores de un bucle para recorrer en iteración una colección. El valor de índice de una colección es un índice de base cero, por lo que debe restar uno de la variable de bucle; de lo contrario, superará los límites superiores de la colección y producirá una excepción.

Se aplica a

Consulte también