Stop auto scroll with DBGrid
Posted: 28.09.2014, 21:11
Hi All,
I have an irritating issue with Delphi, SQLite, Zeos and a DBGrid.
If I have a database of say 300 items and the DBGrid had that has 7 visible rows.
I have an OnCellClick event that toggles a Boolean.
tblShop.Edit;
tblShop.FieldByName('Active').AsBoolean:=not(tblShop.FieldByName('Active').AsBoolean);
tblShop.Post;
If the row I want to toggle is Item 135 which is at Row 6 and I click, the boolean is toggled, but then the table scrolls so that Item 135 moves to Row 4.
This is crazy stuff as it leaves the user with the cursor where item 135 used to be and now over item 137. With 7 rows in this example, not too big of a deal, but with 20 visible rows, it is insanely annoying as it does it above and below the center row always having focus.
Is there some way to turn of this auto-vertical-centering?
e.g. I start with this...
Row 1, item 130
Row 2, item 131
Row 3, item 132
Row 4, item 133
Row 5, item 134
Row 6, item 135 <-- if I click here
Row 7, Item 136
this is what I get...
Row 1, item 132
Row 2, item 133
Row 3, item 134
Row 4, item 135 <-- Row I just edited gets moved up to here
Row 5, item 136
Row 6, item 137 <-- cursor still here
Row 7, Item 138
The reverse happens if I click above the center line Row, the damned thing moves the edited line down to the center row.
How can I disable this crazy behavior?
I have tried with a different set of data aware DB components and it does not happen. It is something the Zeos dbgrid component is doing.
Thanks
I have an irritating issue with Delphi, SQLite, Zeos and a DBGrid.
If I have a database of say 300 items and the DBGrid had that has 7 visible rows.
I have an OnCellClick event that toggles a Boolean.
tblShop.Edit;
tblShop.FieldByName('Active').AsBoolean:=not(tblShop.FieldByName('Active').AsBoolean);
tblShop.Post;
If the row I want to toggle is Item 135 which is at Row 6 and I click, the boolean is toggled, but then the table scrolls so that Item 135 moves to Row 4.
This is crazy stuff as it leaves the user with the cursor where item 135 used to be and now over item 137. With 7 rows in this example, not too big of a deal, but with 20 visible rows, it is insanely annoying as it does it above and below the center row always having focus.
Is there some way to turn of this auto-vertical-centering?
e.g. I start with this...
Row 1, item 130
Row 2, item 131
Row 3, item 132
Row 4, item 133
Row 5, item 134
Row 6, item 135 <-- if I click here
Row 7, Item 136
this is what I get...
Row 1, item 132
Row 2, item 133
Row 3, item 134
Row 4, item 135 <-- Row I just edited gets moved up to here
Row 5, item 136
Row 6, item 137 <-- cursor still here
Row 7, Item 138
The reverse happens if I click above the center line Row, the damned thing moves the edited line down to the center row.
How can I disable this crazy behavior?
I have tried with a different set of data aware DB components and it does not happen. It is something the Zeos dbgrid component is doing.
Thanks