BindingManagerBase.Position 属性 [C#]请参见
当在派生类中被重写时,获取或设置绑定到该数据源的控件所指向的基础列表中的位置。
[C#]
public abstract int Position {get; set;}
属性值
指定基础列表中某个位置的从零开始的索引。
备注
使用 Position 循环访问 BindingManagerBase 所维护的基础列表。若要转到第一项,请将 Position 设置为零。若要转到列表的末尾,请将 Position 设置为 Count 属性的值减一。
当 Position 属性值更改时发生 PositionChanged 事件。
示例
[C#] 下面的示例展示设置 Position 属性的四种方法。MoveNext 方法使该属性增加一。MovePrevious 方法使该属性减少一。MoveFirst 将该属性设置为 0,而 MoveLast 将该属性设置为 Count 属性的值减一。
[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;
}