Delphi Programming

  1. Home
  2. Computing & Technology
  3. Delphi Programming
photo of Zarko Gajic

Zarko's Delphi Programming Blog

By Zarko Gajic, About.com Guide to Delphi Programming since 1998

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

May 12, 2008 at 2:33 pm
(1) Daniel Alves Grillo says:

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;

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

Discuss

Community Forum

Explore Delphi Programming

About.com Special Features

Build Your Own Website

Step-by-step advice on how to do everything from choosing a Web host to promoting your content. More >

Connect Your Home Computers

Easy ways to connect two computers for networking purposes. More >

Delphi Programming

  1. Home
  2. Computing & Technology
  3. Delphi Programming

©2009 About.com, a part of The New York Times Company.

All rights reserved.