BindingManagerBase.Position Property

Definition

当在派生类中被重写时,获取或设置绑定到该数据源的控件所指向的基础列表中的位置。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

Property Value

Int32

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

Examples

下面的代码示例演示了设置 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. MoveFirst 方法将属性设置为0,MoveLast 方法将属性设置为 Count 属性减1的值。The 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

Remarks

使用 Position 属性可循环访问 BindingManagerBase维护的基础列表。Use 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. 若要前进到列表的末尾,请将 Position 设置为 Count 属性减1的值。To go to the end of the list, set the Position to the value of the Count property minus 1.

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

Applies to

See also