Solved

Scrollbars and TDBGrid

Posted on 1998-08-10
10
1,190 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 150 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

726 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