Freigeben über


CurrencyManager.Position-Eigenschaft

Ruft die Position ab, an der Sie sich in der Liste befinden, oder legt diese Position fest.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

Syntax

'Declaration
Public Overrides Property Position As Integer
'Usage
Dim instance As CurrencyManager
Dim value As Integer

value = instance.Position

instance.Position = value
public override int Position { get; set; }
public:
virtual property int Position {
    int get () override;
    void set (int value) override;
}
/** @property */
public int get_Position ()

/** @property */
public void set_Position (int value)
public override function get Position () : int

public override function set Position (value : int)

Eigenschaftenwert

Eine Zahl zwischen 0 (null) und Count minus 1.

Hinweise

Eine wichtige Eigenschaft der CurrencyManager-Klasse ist die Position-Eigenschaft. In einer Liste von Elementen kann nur eines der Elemente der gesamten Liste angezeigt werden. Legen Sie Position auf eine Zahl zwischen 0 (null; Anfang der Liste) und Count minus 1 (Ende der Liste) fest, um zu bestimmen, welches Element angezeigt wird.

Daher legt Position die Währung oder Position in der Liste aller gebundenen Steuerelemente auf denselben CurrencyManager fest. Angenommen, eine Liste besteht aus zwei Spalten, "FirstName" und "LastName". Zwei TextBox-Steuerelemente werden an dieselbe Liste gebunden. Das erste Steuerelement wird an die erste Spalte und das zweite Steuerelement an die zweite Spalte gebunden. Wenn die Position des allgemeinen CurrencyManager auf die dritte Position festgelegt ist, zeigen beide Steuerelemente die entsprechenden Werte für diese Position in der Liste an. Wenn das Element an der dritten Position aus dem Vornamen "John" und dem Nachnamen "Smith" besteht, zeigen die gebundenen Steuerelemente "John" und "Smith" an.

Beispiel

In den folgenden Codebeispielen ist kann mithilfe der Position-Eigenschaft durch eine Liste navigiert werden.

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
   
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:
   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.get_Count() == 0) {
        Console.WriteLine("No records to move to.");
        return ;
    }
    if (myCurrencyManager.get_Position() == 
        myCurrencyManager.get_Count() - 1) {
        Console.WriteLine("You're at end of the records");
    }
    else {
        myCurrencyManager.set_Position(
            myCurrencyManager.get_Position() + 1);
    }
} //MoveNext

private void MoveFirst(CurrencyManager myCurrencyManager)
{
    if (myCurrencyManager.get_Count() == 0) {
        Console.WriteLine("No records to move to.");
        return ;
    }
    myCurrencyManager.set_Position(0);
} //MoveFirst

private void MovePrevious(CurrencyManager myCurrencyManager)
{
    if (myCurrencyManager.get_Count() == 0) {
        Console.WriteLine("No records to move to.");
        return;
    }
    if (myCurrencyManager.get_Position() == 0) {
        Console.WriteLine("You're at the beginning of the records.");
    }
    else {
        myCurrencyManager.set_Position(
            myCurrencyManager.get_Position() - 1);
    }
} //MovePrevious

private void MoveLast(CurrencyManager myCurrencyManager)
{
    if (myCurrencyManager.get_Count() == 0) {
        Console.WriteLine("No records to move to.");
        return ;
    }
    myCurrencyManager.set_Position(myCurrencyManager.get_Count() - 1);
} //MoveLast
private function MoveNext(myCurrencyManager : CurrencyManager){
    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 function MoveFirst(myCurrencyManager : CurrencyManager){
    if(myCurrencyManager.Count == 0) {
       Console.WriteLine("No records to move to.");
       return;
    }
 
    myCurrencyManager.Position = 0;
 }
 
 private function MovePrevious(myCurrencyManager : CurrencyManager){
    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 function MoveLast(myCurrencyManager : CurrencyManager){
    if(myCurrencyManager.Count == 0) {
       Console.WriteLine("No records to move to.");
       return;
    }
    myCurrencyManager.Position = myCurrencyManager.Count - 1;
 }
   

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

.NET Compact Framework

Unterstützt in: 2.0, 1.0

Siehe auch

Referenz

CurrencyManager-Klasse
CurrencyManager-Member
System.Windows.Forms-Namespace
CurrencyManager.List-Eigenschaft
CurrencyManager.Count-Eigenschaft
CurrencyManager.Current-Eigenschaft