This documentation is archived and is not being maintained.

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.

[Visual Basic]
Public MustOverride Property Position As Integer
[C#]
public abstract int Position {get; set;}
[C++]
public: __property virtual int get_Position() = 0;
public: __property virtual void set_Position(int) = 0;
[JScript]
public abstract function get Position() : int;
public abstract function set Position(int);

Property Value

A zero-based index that specifies a position in the underlying list.

Remarks

Use the Position to iterate through the underlying list maintained by the BindingManagerBase. To go to the first item, set the Position to zero. To go to the end of the list, set the Position to the value of the Count property minus one.

The PositionChanged event occurs when the Position property value changes.

Example

[Visual Basic, C#, C++] The following example shows four methods that set the Position property. The MoveNext method increments the property by one. The MovePrevious method decrements the property by one. MoveFirst sets the property to 0, and MoveLast sets the property to the value of the Count property minus one.

[Visual Basic] 
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

[C#] 
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;
}
   

[C++] 
private:
void BindingManagerBase_CurrentChanged
(Object* sender, EventArgs* /*e*/)
{
   // Print the new value of the current object.
   Console::Write(S"Current Changed: ");
   Console::WriteLine((dynamic_cast<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;
}
   

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

BindingManagerBase Class | BindingManagerBase Members | System.Windows.Forms Namespace

Show: