I need to display the current record as the topmost line in my dbgrid after
I move the cursor of the dataset by program.
I tried a construction like:
type
TCustomDBGridCracker = class(TCustomDBGrid);
...
with TCustomDBGridCracker(dbgData) do
...
But I do not get further what to place after the "do" ;-(.
Thanks for your suggestions.
Heiko
>I need to display the current record as the topmost line in my dbgrid after
>I move the cursor of the dataset by program.
Here is a method that I use in a subclassed DBGrid. You can move to
the top row with:
MoveToRow(TopRow);
procedure TMyDBGrid.MoveToRow(NewRow: Integer);
// Scrolls the visible records so that the current record is shown
// on the NewRow position (if possible)
var
Mark: TBookmarkStr;
begin
Mark := DataLink.DataSet.Bookmark;
// Set the current row to NewRow
// (this also moves the record pointer)
DataLink.ActiveRecord := NewRow;
// Goto the original record
DbiSetToBookmark(TDBDataSet(DataLink.DataSet).Handle,
Pointer(Mark));
// Force a reread of the record buffer with the current settings
DataLink.DataSet.Resync([rmExact]);
end;
Row, TopRow and DataLink are protected properties of DBGrid, so they
should be used in a DBGrid subclass.
Jan