procedure TForm1.CopyDataClick(Sender: TObject);var SavePlace: TBook; begin with dbgrid.datasource.dataset do begin { get a book so that we can return to the same record } SavePlace := GetBook; try dbgrid.refresh; if bookMarkValid(savePlace) then GotoBook(SavePlace) else first; //delete { Free the book } finally FreeBook(SavePlace); end; end;end;
刷新后再用locate定位就可以了
只有这个办法
先用GerBook给一个TBook实例赋值, 当想回到原来位置时, 调用GotoBook();
SavePlace: TBook;
begin
with dbgrid.datasource.dataset do
begin
{ get a book so that we can return to the same record }
SavePlace := GetBook;
try
dbgrid.refresh;
if bookMarkValid(savePlace) then
GotoBook(SavePlace)
else
first; //delete
{ Free the book }
finally
FreeBook(SavePlace);
end;
end;end;