CurrencyManager.Count CurrencyManager.Count CurrencyManager.Count CurrencyManager.Count Property

Définition

Obtient le nombre d'éléments contenus dans la liste.Gets the number of items in the list.

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

Valeur de propriété

Nombre d'éléments de la liste.The number of items in the list.

Exemples

L’exemple de code suivant itère au sein de la liste jusqu’à ce que l’élément Count final, déterminé par la propriété, soit atteint.The following code example iterates through the list until the final item, determined by the Count property, is reached.

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

Remarques

Utilisez la propriété Count pour déterminer à quel moment la fin d’une liste a été atteinte.Use the count property to determine when the end of a list has been reached. Étant donné CurrencyManager que le gère un tableau d’éléments de base 0, la fin de la liste Count est toujours moins un.Because the CurrencyManager maintains a 0-based array of items, the end of the list is always Count minus one.

S’applique à

Voir aussi