CurrencyManager.Position Property

Definition

Obtient ou définit votre position dans la liste.Gets or sets the position you are at within the list.

public:
 virtual property int Position { int get(); void set(int value); };
public override int Position { get; set; }
member this.Position : int with get, set
Public Overrides Property Position As Integer

Property Value

Int32

Nombre compris entre 0 et Count moins 1.A number between 0 and Count minus 1.

Examples

Les exemples de code suivants utilisent la propriété Position pour permettre la navigation dans une liste.The following code examples use the Position property to allow navigation through a list.

private:
   void MoveNext( CurrencyManager^ myCurrencyManager )
   {
      if ( myCurrencyManager->Count == 0 )
      {
         Console::WriteLine( "No records to move to." );
         return;
      }

      if ( myCurrencyManager->Position == myCurrencyManager->Count - 1 )
      {
         Console::WriteLine( "You're at end of the records" );
      }
      else
      {
         myCurrencyManager->Position += 1;
      }
   }

   void MoveFirst( CurrencyManager^ myCurrencyManager )
   {
      if ( myCurrencyManager->Count == 0 )
      {
         Console::WriteLine( "No records to move to." );
         return;
      }

      myCurrencyManager->Position = 0;
   }

   void MovePrevious( CurrencyManager^ myCurrencyManager )
   {
      if ( myCurrencyManager->Count == 0 )
      {
         Console::WriteLine( "No records to move to." );
         return;
      }

      if ( myCurrencyManager->Position == 0 )
      {
         Console::WriteLine( "You're at the beginning of the records." );
      }
      else
      {
         myCurrencyManager->Position -= 1;
      }
   }

   void MoveLast( CurrencyManager^ myCurrencyManager )
   {
      if ( myCurrencyManager->Count == 0 )
      {
         Console::WriteLine( "No records to move to." );
         return;
      }
      myCurrencyManager->Position = myCurrencyManager->Count - 1;
   }
private void MoveNext(CurrencyManager myCurrencyManager){
    if(myCurrencyManager.Count == 0) {
       Console.WriteLine("No records to move to.");
       return;
    }
    if (myCurrencyManager.Position == myCurrencyManager.Count - 1){
       Console.WriteLine("You're at end of the records");
    }
    else{
      myCurrencyManager.Position += 1;
    }
 }
 
 private void MoveFirst(CurrencyManager myCurrencyManager){
    if(myCurrencyManager.Count == 0) {
       Console.WriteLine("No records to move to.");
       return;
    }
 
    myCurrencyManager.Position = 0;
 }
 
 private void MovePrevious(CurrencyManager myCurrencyManager){
    if(myCurrencyManager.Count == 0) {
       Console.WriteLine("No records to move to.");
       return;
    }
    if(myCurrencyManager.Position == 0) {
       Console.WriteLine("You're at the beginning of the records.");
    }   
    else{
       myCurrencyManager.Position -= 1;
    }
 }
 
 private void MoveLast(CurrencyManager myCurrencyManager){
    if(myCurrencyManager.Count == 0) {
       Console.WriteLine("No records to move to.");
       return;
    }
    myCurrencyManager.Position = myCurrencyManager.Count - 1;
 }
   
Private Sub MoveNext(ByVal myCurrencyManager As CurrencyManager)
    If myCurrencyManager.Count = 0 Then
       Console.WriteLine("No records to move to.")
       Exit Sub
    End If
 
    If myCurrencyManager.Position = myCurrencyManager.Count - 1 Then 
       MessageBox.Show("You're at end of the records")
    Else
       myCurrencyManager.Position += 1
    End If
 End Sub
 
 Private Sub MoveFirst(ByVal myCurrencyManager As CurrencyManager)
    If myCurrencyManager.Count = 0 Then
       Console.WriteLine("No records to move to.")
       Exit Sub
    End If
 
    myCurrencyManager.Position = 0
 End Sub
 
 Private Sub MovePrevious(ByVal myCurrencyManager As CurrencyManager)
    If myCurrencyManager.Count = 0 Then
       Console.WriteLine("No records to move to.")
       Exit Sub
    End If
 
    If myCurrencyManager.Position = 0 Then
       MessageBox.Show("You're at the beginning of the records.")
    Else
       myCurrencyManager.Position -= 1
    End if
 End Sub
 
 Private Sub MoveLast(ByVal myCurrencyManager As CurrencyManager)
    If myCurrencyManager.Count = 0 Then
       Console.WriteLine("No records to move to.")
       Exit Sub
    End If
 
    myCurrencyManager.Position = myCurrencyManager.Count - 1
 End Sub
   

Remarks

La propriété Position est une propriété importante de la classe CurrencyManager.An important property of the CurrencyManager class is the Position property. Dans une liste d’éléments, vous ne pouvez afficher qu’un seul élément dans la liste entière.In a list of items, you can view only one item out of the entire list. Pour déterminer l’élément à afficher, définissez le Position sur un nombre compris entre 0 (le début de la liste) et Count moins 1 (la fin de la liste).To determine which item is viewed, set the Position to a number between 0 (the beginning of the list) and Count minus 1 (the end of the list).

Par conséquent, le Position détermine la devise ou l’emplacement dans la liste de tous les contrôles liés au même CurrencyManager.Therefore, the Position determines the currency, or place in the list, of all controls bound to the same CurrencyManager. Par exemple, Imaginez une liste composée de deux colonnes appelées « FirstName » et « LastName ».For example, imagine a list consisting of two columns called "FirstName" and "LastName". Deux contrôles TextBox sont liés à la même liste ; le premier contrôle est lié à la première colonne, et le deuxième contrôle est lié à la deuxième colonne.Two TextBox controls are bound to the same list; the first control is bound to the first column, and the second control is bound to the second column. Lorsque la Position du CurrencyManager commun est définie sur la troisième position, les deux contrôles affichent les valeurs appropriées pour cette position dans la liste.When the Position of the common CurrencyManager is set to the third position, both controls display the appropriate values for that position in the list. En d’autres termes, si l’élément situé à la position trois comprend le prénom « John » et le nom « Smith », les contrôles liés affichent « John » et « Smith ».In other words, if the item at position three consists of the first name "John" and the last name "Smith", the bound controls will display "John" and "Smith".

Applies to

See also