Located record in DBGrid

On Wed, 16 Feb 2000 00:57:15 +1100, Lance Harris

Quote
<lance...@zeta.org.au> wrote:
><br>It works fine but the found record appears in the middle of the DBGrid.
><br>Is there a way to have the found (Located) record move to the top of
>the DBGrid instead of the middle?

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

P.S. Could you post your message in text-only?  It is kind off hard to
read here.