解決dev GridControl 重新整理資料後,滾動條恢復原來位置
阿新 • • 發佈:2019-01-03
找了半天scroll,結果卻是TopRowIndex的事。
1、觸發GridView_TopRowChanged()事件
2、設定TopRowIndex
int topIndex = -1;
private void gridView2_TopRowChanged(object sender, EventArgs e)
{
topIndex = gridView2.TopRowIndex;
}
private void refreshView2()
{
string sql = "select * from [A資料分析表]";
DataTable dt= db.GetTable(sql);
gridControl2.DataSource = dt;
gridView2.TopRowIndex = topIndex;//就是這句
}
private void button1_Click(object sender, EventArgs e)
{
refreshView2();
}