?
Solved

Scrollbars and TDBGrid

Posted on 1998-08-10
10
Medium Priority
?
1,198 Views
Last Modified: 2012-05-04
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??
0
Comment
Question by:Reality
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
10 Comments
 

Author Comment

by:Reality
ID: 1361837
Edited text of question
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1361838
Reality, can you be more specific? Zif.
0
 

Author Comment

by:Reality
ID: 1361839
Edited text of question
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Expert Comment

by:ZifNab
ID: 1361840
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.
0
 
LVL 10

Expert Comment

by:Jacco
ID: 1361841
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
0
 

Author Comment

by:Reality
ID: 1361842
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.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1361843
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.
0
 
LVL 8

Accepted Solution

by:
ZifNab earned 600 total points
ID: 1361844
The remove the vertical scrollbar use this code :

unit Newgrid;

interface

uses
  WinTypes, WinProcs, Classes, DBGrids;

type
  TNoVertScrollDBGrid = class(TDBGrid)
  protected
    procedure Paint; override;
  end;

procedure Register;

implementation

procedure TNoVertScrollDBGrid.Paint;
begin
  SetScrollRange(Self.Handle, SB_VERT, 0, 0, False);
  inherited Paint;
end;

procedure Register;
begin
  RegisterComponents('Data Controls', [TNoVertScrollDBGrid]);
end;

end.

No further, use a panel. Put your scrollbar on it (RightAlign). Put the new grid on it. (Align = client).

And use above code (in previous comment) to move scrollbar with grid.

Zif.


0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1361845
reality, be sure you use it for small tables only... Otherwise speed will drop significantly
0
 

Author Comment

by:Reality
ID: 1361846
Very fast and very clear.  Thanks for your help...I can now return to my plans!!  Bwahahaha!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month14 days, 18 hours left to enroll

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question