title: Delphi - restore actual row in DBGrid
body: <p>D6 prof.</p>
  
  <p>Formerly we used DBISAM and DBISAMTable. That handle the RecNo, and it is working good with modifications (Delete, edit, etc).</p>
  
  <p>Now we replaced with ElevateDB, that don't handle RecNo, and many times we use Queries, not Tables.</p>
  
  <p>Query must reopen to see the modifications.</p>
  
  <p>But if we Reopen the Query, we need to repositioning to the last record.
  Locate isn't enough, because Grid is show it in another Row.
  This is very disturbing thing, because after the modification record is moving into another row, you hard to follow it, and users hate this.</p>
  
  <p>We found this code:</p>
  
  <pre><code>function TBaseDBGrid.GetActRow: integer;
  begin
   Result := -1 + Row;
  end;
  
  
  procedure TBasepDBGrid.SetActRow(aRow: integer);
  var
   bm : TBookMark;
  begin
   if IsDataSourceValid(DataSource) then with DataSource.DataSet do begin
    bm := GetBookmark;
    DisableControls;
    try
     MoveBy(-aRow);
     MoveBy(aRow);
     //GotoBookmark(bm);
    finally
     FreebookMark(bm);
     EnableControls;
    end;
   end;
  end;
  </code></pre>
  
  <p>The original example is uses moveby. This working good with Queries, because we cannot see that Query reopened in the background, the visual control is not changed the row position.</p>
  
  <p>But when we have EDBTable, or Live/Sensitive Query, the MoveBy is dangerous to use, because if somebody delete or append a new row, we can relocate into wrong record.</p>
  
  <p>Then I tried to use the BookMark (see remark). But this technique isn't working, because it is show the record in another Row position...</p>
  
  <p>So the question: how to force both the row position and record in DBGrid?</p>
  
  <p>Or what kind of DBGrid can relocate to the record/row after the underlying DataSet refreshed?</p>
  
  <p>I search for user friendly solution, I understand them, because I tried to use this jump-across DBGrid, and very bad to use, because my eyes are getting out when try to find the original record after update... :-(</p>
  
  <p>Thanks for your every help, link, info:
     dd</p>