Link to home
Start Free TrialLog in
Avatar of Reality
Reality

asked on

Scrollbars and TDBGrid

How do I synchonise a vertical scroll bar with a TDBGrid so that it actually moves at the same rate as the grid and is proportionally sized??

With a grid full of data that is longer than the display area, clicking on the scrol bar (or the arrows) takes the button on the scroll bar down to half way, where it then stays until the end of the table is reached (where it tests for BOF/EOF I guess).

Is there anyway to get the button the scroll bar to move down the correct amount each time the scroll bar is moved ie. only a little way down if you click on an arrow, a page legth down if you click on the scroll bar, enabling you to drag it to another part of the table.

Also in some apps, the scroll bar button is sized proportionally to the amount of text on the screen...if there is much more text to see the button is smaller, bigger if the text only just goes off of the screen.  Is there any way of achieving this??
Avatar of Reality
Reality

ASKER

Edited text of question
Reality, can you be more specific? Zif.
Avatar of Reality

ASKER

Edited text of question
Sorry, Reality still don't understand your question. especially with scrollbar button? Which scrollbar button do you mention, you only have arrow-buttons... maybe you can address us to an url with a sample of what you need.

For scrollbar :

 what you can do is placing a scrollbar over the scrollbar of the dbgrid (make this one invisible) and handle the scrollbar yourself :

Scrollbar1:TScrollBar;

Initialization:
Scrollbar1.setparams(0,0,table1.recordcount);

procedure Tform1.DataSource1DataCharge(Sender:TObject;Field:TField);
begin
   scrollbar1.position:=table1.recno;
end

procedure Tform1.ScrollBar1Change(Sender:TObject);
begin
lastscrollposition:=table1.recno;
table1.moveby(Scrollbar1.position-lastscrollposition);
end

not so a fancy solution dough.

Zif.
The normal DBGrid doesn't do what you want, and for a good reason. When the cursor is opened the DBGird does not do a record count since this consumes to much time. That is the reason why the scrollbar doesn't show correctly.

You can make a new DBGrid but that requires a lot of work and the new component cannot be used on large tables then because of the time.

Regards Jacco
Avatar of Reality

ASKER

I had a sneaking suspicion it wouldn't be a simple thing to do! :>

By the button on a scroll bar I mean that thing that moves up and down as you move the scroll bar...I guess a slider would have been a better name, but I didn't think of that name at the time.

Re Jacco...how big is a big table??  I think it'll only be used on a small table, so is there anyway of just replacing the scroll bar on a component and inheriting all the rest??

Thanks.
reality,

'so is there anyway of just replacing the scroll bar on a component and inheriting all the rest??' Yes...

Look at my previous comment. Just make verticle scrollbar invisible and place your own one aside.... then you only change the scrollbar... And you can use any fancy scrollbar too!

Zif.
ASKER CERTIFIED SOLUTION
Avatar of ZifNab
ZifNab

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
reality, be sure you use it for small tables only... Otherwise speed will drop significantly
Avatar of Reality

ASKER

Very fast and very clear.  Thanks for your help...I can now return to my plans!!  Bwahahaha!