CurrencyManager.Position プロパティ

定義

リスト内の現在の位置を取得または設定します。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

プロパティ値

0 から Count -1 までの数値。A number between 0 and Count minus 1.

次のコード例ではPosition 、プロパティを使用して、リスト内のナビゲーションを許可しています。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
   

注釈

CurrencyManagerクラスの重要なプロパティは、 Positionプロパティです。An important property of the CurrencyManager class is the Position property. 項目の一覧では、リスト全体から1つの項目のみを表示できます。In a list of items, you can view only one item out of the entire list. どの項目を表示するかを決定するPositionには、を 0 (リストの先頭Count ) から-1 (リストの最後) までの数値に設定します。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).

したがって、 Positionは、同じCurrencyManagerにバインドされているすべてのコントロールの通貨を判断するか、リスト内に配置します。Therefore, the Position determines the currency, or place in the list, of all controls bound to the same CurrencyManager. たとえば、"FirstName" と "LastName" という2つの列で構成されるリストがあるとします。For example, imagine a list consisting of two columns called "FirstName" and "LastName". 2 TextBoxつのコントロールが同じリストにバインドされます。1つ目のコントロールは最初の列にバインドされ、2つ目のコントロールは2番目の列にバインドされます。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. Position 共通CurrencyManagerのが3番目の位置に設定されている場合、両方のコントロールに、リスト内のその位置に対する適切な値が表示されます。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. つまり、3番目の位置にある項目が名 "John" と姓 "Smith" で構成されている場合、バインドされたコントロールには "John" と "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".

適用対象

こちらもご覧ください