How to Refresh a DBGrid without Losing the Current Row Position
Monday May 12, 2008
in Delphi TIPS :: When DBGrid is used to display data from a dataset (query or table), by design, after you call Refresh method on a dataset (re-open) (for example, using a DBNavigator), the current row position will be set to zero (first record).
If you have been asking "Is there any way to reopen or refresh a query, leaving the TDBGrid data exactly where it is (without changing the positions)?" Here's one answer to the problem...
Read the full article to learn how to Refresh DBGrid Data - Preserve Row Position.
Related:


Comments
I do this using Bookmark in the dataset
procedure RefreshDataSet(Dset: TIBDataSet);
var
P: Pointer;
begin
P := Dset.GetBookmark;
try
Dset.Close;
Dset.Open;
if dset.BookmarkValid(P) then
Dset.GotoBookmark(P);
finally
Dset.FreeBookmark(P);
end;
end;