title: How can I restore a TDBGrid record view to the condition before a refresh?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/8599260/how-to-avoid-tdbgrid-scrolling-when-returning-to-a-previous-location">How to avoid TDbgrid scrolling when returning to a previous location</a>  </p>
  </blockquote>
  
  
  
  <p>I am looking for a way to save and restore the vertical scrolling position of a Delphi <code>TDBGrid</code> after a refresh has occurred. Currently, the grid resets itself so that the selected record appears in the middle of the list of records.</p>
  
  <p>At first, the properties <code>LeftCol</code> and <code>TopRow</code> appeared to be the solution, but only <code>LeftCol</code> works. The <code>TopRow</code> value is always 1 and never changes. It appears to be a position into the internal record buffer of the grid, which is set to the number of rows displaying in the grid. That is, it appears that FBuffers slides up and down, but <code>TopRow</code> remains 1 at all times.</p>
  
  <p>A detailed example of what I'm seeing is:</p>
  
  <ul>
  <li>The grid displays 11 records of a <code>TClientDataSet</code>, starting with record 5, displayng sequentially to record 15.  </li>
  <li>The selected record cursor is on record 15 (the last record in the view).  </li>
  <li>The dataset is refreshed through a <code>TDataSetProvider</code> linked to a <code>TADODataSet</code>. (An .Open or .Refresh call).  </li>
  <li>The dataset.Locate method is used to retain the actual selected record in the face of insertions/deletions.  </li>
  <li>The grid changes so that record 15 is in the center and it is displaying records 10 through 20.</li>
  </ul>
  
  <p>Is there anything that can be saved/restored/performed so that the grid can be restored to its original viewing configuration showing records 5-15 with the cursor on the same selected record, wherever it appears?</p>
  
  <p>The closest thing I can find in my many search attempts is an issue that was solved in Delphi 3.0 with TopRow, LeftCol, here: <a href="http://www.delphigroups.info/2/79/314206.html" rel="nofollow noreferrer">http://www.delphigroups.info/2/79/314206.html</a></p>
  
  <p>Spelunking through DBGrids.pas isn't netting me a method of locating the buffer pointers relative the underlying dataset records either.</p>