BindingManagerBase.Position 属性

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

**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)

语法

声明
Public MustOverride Property Position As Integer
用法
Dim instance As BindingManagerBase
Dim value As Integer

value = instance.Position

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

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

public abstract function set Position (value : int)

属性值

指定基础列表中某个位置的从零开始的索引。

备注

使用 Position 属性循环访问 BindingManagerBase 所维护的基础列表。若要转到第一项,请将 Position 设置为 0。若要转到列表末尾,请将 Position 的值设置 Count 属性值减 1。

Position 属性值更改时发生 PositionChanged 事件。

示例

下面的代码示例演示设置 Position 属性的四种方法。MoveNext 方法按 1 递增该属性。MovePrevious 方法按 1 递减该属性。MoveFirst 方法将该属性设置为 0。MoveLast 方法将该属性的值设置为 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 'BindingManagerBase_CurrentChanged


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


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


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


Private Sub MoveLast()
    ' Go to the last row in the list.
    myBindingManagerBase.Position = myBindingManagerBase.Count - 1
End Sub 'MoveLast
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:
   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)).get_Current());
} //BindingManagerBase_CurrentChanged

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

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

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

private void MoveLast()
{
    // Go to the last row in the list.
    myBindingManagerBase.set_Position(myBindingManagerBase.get_Count() - 1);
} //MoveLast

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

.NET Compact Framework

受以下版本支持:2.0、1.0

请参见

参考

BindingManagerBase 类
BindingManagerBase 成员
System.Windows.Forms 命名空间
PositionChanged
BindingManagerBase.Current 属性
BindingManagerBase.Count 属性