TDataSet.Bookmark property
Get or set the current cursor position.
Declaration
property Bookmark: TBookMark read GetBookmark write GotoBookmark;Description
Bookmark can be read to obtain a bookmark to the current position in the dataset.
The obtained value can be used to return to current position at a later stage.
Writing the
Bookmark property with a value previously obtained like this,
will reposition the dataset on the same position as it was when the property was read.
This is often used when scanning all records, like this:
Var
B : TBookmark;
begin
With MyDataset do
begin
B:=Bookmark;
DisableControls;
try
First;
While Not EOF do
begin
DoSomething;
Next;
end;
finally
EnableControls;
Bookmark:=B;
end;
end;
At the end of this code, the dataset will be positioned on the same record as when the code was started. The DisableControls and EnableControls calls prevent the controls from receiving update notifications as the dataset scrolls through the records, thus reducing flicker on the screen.
Note that bookmarks become invalid as soon as the dataset closes. A call to refresh may also destroy the bookmarks.
See also
An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
