Delphi - restore actual row in DBGrid

后端 未结 4 2010
野趣味
野趣味 2021-01-03 03:47

D6 prof.

Formerly we used DBISAM and DBISAMTable. That handle the RecNo, and it is working good with modifications (Delete, edit, etc).

Now we replaced with

4条回答
  •  囚心锁ツ
    2021-01-03 03:52

    Just simple piece of code that came in my mind:

    procedure DoRefresh(Dataset: TDataset);
    var
      bkm: TBookmark;
    begin
      Dataset.UpdateCursorPos;
      bkm := Dataset.GetBookmark;
      Dataset.DisableControls;
      try
        Dataset.Refresh;  //refresh dataset if it's open
    
        if Dataset.BookmarkValid(bkm) then
        begin
          Dataset.GotoBookmark(bkm);
        end;
      finally
        Dataset.EnableControls;
        Dataset.FreeBookmark(bkm);
      end;
    end;
    

提交回复
热议问题