我知道一个条件可以在datafrid控件中找到确定的一行.
我怎么才能得到这行的行号,我怎么样让datagrid自动滚动到那一行.
谢谢大虾们的帮助.
BindingContext[yourDataSource].Position=index;
index为你所选的行的索引
或者
直接
DataGrid.Select(index);
The DataGrid has a protected GridVScrolled member that can be used to scroll the grid. To use it , you can derive from DataGrid and and a ScrollToRow method.
class MyDataGrid : DataGrid
{
public ScrollToRow(int row)
{
this.GridVScrolled(this, ScrollEventArgs(Type.LargeIncrement, row));
}
}
未经测试。
看起来GirdVScrolled应该是protected event。DataGrid既然没有提供访问这个protected成员的public方法或属性,所以只能继承后用public方法访问啦。不过,这种机制的作用是什么?俺一时想不明白。