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;
For some reason calling: "Grid.MoveToRow(0);" causes the App to Crash.
Behind the Grid is a TDatasource and A TClientDataSet created in memory.
TMyDB Grid is my own component. I use it to put the current Highlighted row
in a grid as the first row in the grid (even if it is not the first record
in the DataSet).
S