Link to home
Start Free TrialLog in
Avatar of tondog
tondog

asked on

In Delphi, How do I move the record pointer to the middle of the DBGrid's visible rows?

How do I move the record pointer to the middle of the DBGrid's visible rows?

In other words, if the height of the DBGrid is showing rows 21-43, then I want to move the pointer to row 31 or so.

(It doesn't have to be exact, i can just do integer division with DIV)

I was able to use:

THackCustomGrid(DBGrid1).VisibleRowCount;

to get the number of visible rows.

But when I used

THackCustomGrid(DBGrid1).TopRow;

this integer value ALWAYS returns the number one.
Avatar of Emmanuel PASQUIER
Emmanuel PASQUIER
Flag of France image

I found the tip you are refering to, it is not working on Delphi 2007 and before. I don't know for others. TopRow is implemented differently as it should in CustomGrid, which is probably why it is hidden in DBGrid.
try to set it to 3 just for fun, you will see it moves the grid 2 lines up but hides the bottom 2 lines

The position of the selected row (selected in the source) in the DBGrid view is ever changing, if you move forward or backward in your dataset it will put it at the top or bottom of the grid's view...

As a general advice, try to avoid using those DBGrid and StringGrid, they are the worst components ever made ! They do their basic stuff, but you get only problems when you want something more elegant or user-friendly.
Avatar of tondog
tondog

ASKER

ah

uhm.. are you saying it can't be done?

Can you recommend a different Grid module?
ASKER CERTIFIED SOLUTION
Avatar of Emmanuel PASQUIER
Emmanuel PASQUIER
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tondog

ASKER

Hmm

also, when i filter my database, the scrollbar really starts messing up.

I guess this is a common problem, as discussed here

https://www.experts-exchange.com/questions/10018314/Scrollbar-in-DBGrid-Delphi-3.html

Do you know if this paid module facilitates filtering?

Can you anyone recommend another way to filter? maybe with sql commands?
> Do you know if this paid module facilitates filtering?

Filtering is done the same way as other DB controls. I don't know specifically if it will solve your filter problem, but these TMS components smell good work. You should try with the demo version if it's ok with your needs.