BindingManagerBase.Position BindingManagerBase.Position BindingManagerBase.Position BindingManagerBase.Position Property

定义

当在派生类中被重写时,获取或设置绑定到该数据源的控件所指向的基础列表中的位置。When overridden in a derived class, gets or sets the position in the underlying list that controls bound to this data source point to.

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

属性值

指定基础列表中某个位置的从零开始的索引。A zero-based index that specifies a position in the underlying list.

示例

下面的代码示例演示了设置Position属性的四个方法。The following code example shows four methods that set the Position property. 方法MoveNext将属性递增1。The MoveNext method increments the property by 1. MovePrevious方法将属性递减1。The MovePrevious method decrements the property by 1. 方法将属性设置为0, MoveLast方法将属性设置Count为属性的值减1。 MoveFirstThe MoveFirst method sets the property to 0, and the MoveLast method sets the property to the value of the Count property minus 1.

private:
   void BindingManagerBase_CurrentChanged( Object^ sender, EventArgs^ /*e*/ )
   {
      // Print the new value of the current object.
      Console::Write( "Current Changed: " );
      Console::WriteLine( ( (BindingManagerBase^)(sender) )->Current );
   }

   void MoveNext()
   {
      // Increment the Position property value by one.
      myBindingManagerBase->Position = myBindingManagerBase->Position + 1;
   }

   void MovePrevious()
   {
      // Decrement the Position property value by one.
      myBindingManagerBase->Position = myBindingManagerBase->Position - 1;
   }

   void MoveFirst()
   {
      // Go to the first item in the list.
      myBindingManagerBase->Position = 0;
   }

   void MoveLast()
   {
      // Go to the last row in the list.
      myBindingManagerBase->Position = myBindingManagerBase->Count - 1;
   }
private void BindingManagerBase_CurrentChanged
(object sender, EventArgs e)
{
   // Print the new value of the current object.
   Console.Write("Current Changed: ");
   Console.WriteLine(((BindingManagerBase)sender).Current);
}

private void MoveNext()
{
   // Increment the Position property value by one.
   myBindingManagerBase.Position += 1;
}

private void MovePrevious()
{
   // Decrement the Position property value by one.
   myBindingManagerBase.Position -= 1;
}

private void MoveFirst()
{
   // Go to the first item in the list.
   myBindingManagerBase.Position = 0;
}

private void MoveLast()
{
   // Go to the last row in the list.
   myBindingManagerBase.Position = 
   myBindingManagerBase.Count - 1;
}
   
Private Sub BindingManagerBase_CurrentChanged(sender As Object, e As EventArgs)
    ' Print the new value of the current object.
    Console.Write("Current Changed: ")
    Console.WriteLine(CType(sender, BindingManagerBase).Current)
End Sub


Private Sub MoveNext()
    ' Increment the Position property value by one.
    myBindingManagerBase.Position += 1
End Sub


Private Sub MovePrevious()
    ' Decrement the Position property value by one.
    myBindingManagerBase.Position -= 1
End Sub


Private Sub MoveFirst()
    ' Go to the first item in the list.
    myBindingManagerBase.Position = 0
End Sub


Private Sub MoveLast()
    ' Go to the last row in the list.
    myBindingManagerBase.Position = myBindingManagerBase.Count - 1
End Sub

注解

使用属性来循环访问BindingManagerBase由维护的基础列表。 PositionUse the Position property to iterate through the underlying list maintained by the BindingManagerBase. 若要前往第一项,请将Position设置为0。To go to the first item, set the Position to 0. 若要前进到列表的末尾,请将设置PositionCount属性的值减1。To go to the end of the list, set the Position to the value of the Count property minus 1.

当属性值更改时发生此PositionChanged事件。 PositionThe PositionChanged event occurs when the Position property value changes.

适用于

另请参阅