CurrencyManager.Position Propriedade

Definição

Obtém ou define a posição em que você está dentro da lista.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

Valor da propriedade

Int32

Um número entre 0 e Count menos 1.A number between 0 and Count minus 1.

Exemplos

Os exemplos de código a seguir usam a Position propriedade para permitir a navegação por meio de uma lista.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
   

Comentários

Uma propriedade importante da CurrencyManager classe é a Position propriedade.An important property of the CurrencyManager class is the Position property. Em uma lista de itens, você pode exibir apenas um item da lista inteira.In a list of items, you can view only one item out of the entire list. Para determinar qual item é exibido, defina Position como um número entre 0 (o início da lista) e Count menos 1 (o final da lista).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).

Portanto, o Position determina a moeda ou o local na lista de todos os controles associados ao mesmo CurrencyManager .Therefore, the Position determines the currency, or place in the list, of all controls bound to the same CurrencyManager. Por exemplo, imagine uma lista que consiste em duas colunas chamadas "FirstName" e "LastName".For example, imagine a list consisting of two columns called "FirstName" and "LastName". Dois TextBox controles são associados à mesma lista; o primeiro controle é associado à primeira coluna e o segundo controle é vinculado à segunda coluna.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. Quando o Position comum CurrencyManager é definido como a terceira posição, ambos os controles exibem os valores apropriados para essa posição na lista.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. Em outras palavras, se o item na posição três consistir no primeiro nome "João" e o sobrenome "Smith", os controles associados exibirão "João" e "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".

Aplica-se a

Confira também