CurrencyManager.Position Propriedade
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Obtém ou definem a posição em que estás dentro da lista.
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 de Propriedade
Um número entre 0 e Count menos 1.
Exemplos
Os seguintes exemplos de código usam a Position propriedade para permitir a navegação através de uma lista.
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
Observações
Uma propriedade importante da CurrencyManager classe é a propriedade Position . Numa lista de itens, só pode ver um item de toda a lista. Para determinar qual o item que é visto, defina-o Position para um número entre 0 (início da lista) e Count menos 1 (o fim da lista).
Portanto, o Position determina a moeda, ou lugar na lista, de todos os controlos ligados ao mesmo CurrencyManager. Por exemplo, imagine uma lista composta por duas colunas chamadas "PrimeiroNome" e "Apelido". Dois TextBox controlos estão ligados à mesma lista; o primeiro controlo está ligado à primeira coluna, e o segundo controlo à segunda coluna. Quando o Position do comum CurrencyManager é definido para a terceira posição, ambos os controlos mostram os valores apropriados para essa posição na lista. Por outras palavras, se o item na posição três consistir no primeiro nome "John" e no apelido "Smith", os controlos vinculados exibirão "John" e "Smith".