Possible Duplicate:
How to avoid TDbgrid scrolling when returning to a previous location
I am looking for a way to save and restore the vertical scrolling position of a Delphi TDBGrid
after a refresh has occurred. Currently, the grid resets itself so that the selected record appears in the middle of the list of records.
At first, the properties LeftCol
and TopRow
appeared to be the solution, but only LeftCol
works. The TopRow
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 TopRow
remains 1 at all times.
A detailed example of what I'm seeing is:
TClientDataSet
, starting with record 5, displayng sequentially to record 15. TDataSetProvider
linked to a TADODataSet
. (An .Open or .Refresh call). 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?
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: http://www.delphigroups.info/2/79/314206.html
Spelunking through DBGrids.pas isn't netting me a method of locating the buffer pointers relative the underlying dataset records either.
Seems that these questions should give you the answer:
How to avoid TDbgrid scrolling when returning to a previous location
Delphi - restore actual row in DBGrid
(esp. this answer)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With