[Lazarus] Control DBGrid row position
Luca Olivetti
luca at wetron.es
Thu Nov 16 17:43:13 CET 2017
El 16/11/17 a les 16:28, Luca Olivetti via Lazarus ha escrit:
> Is there a way to control the position of the selected row in a TDBGrid?
>
> With a TStringGrid you can control it with TopRow, but TDBGrid has no
> such property and I couldn't find a way to do what I want.
>
> I understand that TopRow wouldn't make sense in a DBGrid, but I need the
> same functionality: I have a huge amount of data (let's say 200000
> records), so, in the AfterScroll event of the query, when I'm
> approaching the end or the beginning of the dataset, I modify the query
> to show the previous or next page of data[*] and then reposition (with
> locate) to the same record where it was before changing the query.
>
> It works well but the problem is that, when scrolling downward, the
> selected row jumps every time I do this, i.e., usually it's the bottom
> row, when I go down and reload the data this way, it jumps to the middle
> of the dbgrid[**]. I'd like a way to keep it in the bottom row, so the
> scrolling appears seamless.
An ugly workaround:
moved:=Query.MoveBy(-50);
Query.MoveBy(-moved);
>
> It doesn't happen when scrolling upwards, probably because the dbgrid in
> this case always shows the data on the first row.
>
> Then it would also be nice to control the size and relative position of
> the scrollbar, but that's another matter.
For the time being I just don't show the scrollbar.
Bye
--
Luca Olivetti
Wetron Automation Technology http://www.wetron.es/
Tel. +34 93 5883004 (Ext.3010) Fax +34 93 5883007
More information about the Lazarus
mailing list