This documentation is archived and is not being maintained.

BindingManagerBase.Count Property

When overridden in a derived class, gets the number of rows managed by the BindingManagerBase.

[Visual Basic]
Public MustOverride ReadOnly Property Count As Integer
[C#]
public abstract int Count {get;}
[C++]
public: __property virtual int get_Count() = 0;
[JScript]
public abstract function get Count() : int;

Property Value

The number of rows managed by the BindingManagerBase.

Remarks

Use the Count property to determine the last item in the list of rows maintained by the BindingManagerBase. To go to the last item, set the Position property to the Count property value minus one.

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. 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 | Position

Show: