BindingManagerBase.Count 属性
当在派生类中被重写时,获取 BindingManagerBase 所管理的行数。
**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)
语法
声明
Public MustOverride ReadOnly Property Count As Integer
用法
Dim instance As BindingManagerBase
Dim value As Integer
value = instance.Count
public abstract int Count { get; }
public:
virtual property int Count {
int get () abstract;
}
/** @property */
public abstract int get_Count ()
public abstract function get Count () : int
属性值
BindingManagerBase 所管理的行数。
备注
使用 Count 属性确定 BindingManagerBase 所维护的行列表中的最后一项。若要转到最后一项,请将 Position 属性设置为 Count 属性值减 1。
示例
下面的代码示例演示设置 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 命名空间
Position