Compartir a través de


CurrencyManager.Count Propiedad

Definición

Obtiene el número total de elementos de la lista.

public:
 virtual property int Count { int get(); };
public override int Count { get; }
member this.Count : int
Public Overrides ReadOnly Property Count As Integer

Valor de propiedad

El número de elementos de la lista.

Ejemplos

El siguiente ejemplo de código recorre en iteración la lista hasta que se alcanza el elemento final, determinado por la Count propiedad .

void PrintListItems()
{
   
   // Get the CurrencyManager of a TextBox control.
   CurrencyManager^ myCurrencyManager = dynamic_cast<CurrencyManager^>(textBox1->BindingContext[nullptr]);
   
   // Presuming the list is a DataView, create a DataRowView variable.
   DataRowView^ drv;
   for ( int i = 0; i < myCurrencyManager->Count; i++ )
   {
      myCurrencyManager->Position = i;
      drv = dynamic_cast<DataRowView^>(myCurrencyManager->Current);
      
      // Presuming a column named CompanyName exists.
      Console::WriteLine( drv[ "CompanyName" ] );

   }
}
    private void PrintListItems() {
    // Get the CurrencyManager of a TextBox control.
    CurrencyManager myCurrencyManager = (CurrencyManager)textBox1.BindingContext[0];
    // Presuming the list is a DataView, create a DataRowView variable.
    DataRowView drv;
    for(int i = 0; i < myCurrencyManager.Count; i++) {
        myCurrencyManager.Position = i;
        drv = (DataRowView)myCurrencyManager.Current;
        // Presuming a column named CompanyName exists.
        Console.WriteLine(drv["CompanyName"]);
    }
}
Private Sub PrintListItems()
    ' Get the CurrencyManager of a TextBox control.
    Dim myCurrencyManager As CurrencyManager = CType(textBox1.BindingContext(0), CurrencyManager)
    ' Presuming the list is a DataView, create a DataRowView variable.
    Dim drv As DataRowView
    Dim i As Integer
    For i = 0 To myCurrencyManager.Count - 1
        myCurrencyManager.Position = i
        drv = CType(myCurrencyManager.Current, DataRowView)
        ' Presuming a column named CompanyName exists.
        Console.WriteLine(drv("CompanyName"))
    Next i
End Sub

Comentarios

Utilice la propiedad count para determinar cuándo se ha alcanzado el final de una lista. CurrencyManager Dado que mantiene una matriz basada en 0 de elementos, el final de la lista siempre Count es menos uno.

Se aplica a

Consulte también