简体   繁体   English

如何在devexpress网格中保持当前位置

[英]how to stay at current position in devexpress grid

I use this code to save current selected record after refresh the dataset 刷新数据集后,我使用此代码保存当前选定的记录

bm := table1.GetBookmark;
try
  table1.Refresh;
  table1.GotoBookmark(bm);
finally
  table1.FreeBookmark(bm);
end;

But if I select a record at the middle of the grid, after executing this code it still be current selected record but it jump or make the grid scroll to be the first record in the current view. 但是,如果我在网格的中间选择一条记录,则在执行此代码后,它仍然是当前选择的记录,但是它会跳转或使网格滚动成为当前视图中的第一条记录。 How I can keep current position ? 如何保持当前位置?

Remember current focused row and then set it after refresh. 记住当前焦点所在的行,然后在刷新后进行设置。

Here is example for C# code, but I think, for deplhi it's the same: 这是C#代码的示例,但我认为,对于deplhi来说是相同的:

var row = _gridView.FocusedRowHandle;
_gridView.RefreshData();
_gridView.SelectRow(row);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM