Solved

Scrollbar in DBGrid (Delphi 3)

Posted on 1997-07-25
8
2,960 Views
Last Modified: 2009-07-29
I am Using a DBGrid for accessing dBase files (Delphi 3)
It provides a scroll bar during moving in the database
But the scroll-bar only has 3 states (beginn/middle/end)
Therefore I cannot move in the database using the scrollbar.
This also happens with the Demo-Program (CtrlGrid) provided by Borland

Is there a way to make the scrollbar function correctly ?
0
Comment
Question by:PhiNet
  • 4
  • 3
8 Comments
 

Author Comment

by:PhiNet
ID: 1339770
Edited text of question
0
 
LVL 2

Expert Comment

by:icampbe1
ID: 1339771
You don't say how many rows your grid has.   However, You will find that you have much better control if you drop a DBNavigator on your form and use that.  Delete the buttons you dont want and navigate with the rest.
0
 

Author Comment

by:PhiNet
ID: 1339772
The question was not regarding the navigator.

I am using the navigator already.
I can also navigate with cursor buttons up/dwn etc.

BUT: I intend to use my program as my/and others  standard dBase-Browser
And a scroll is a very helpfull tool.

In my opinion my problem is a bug in Borlands Source code

 As mentioned in my question. You may see the same problem with Delphi's CtrlGrid demo.


0
 
LVL 1

Accepted Solution

by:
millerw earned 100 total points
ID: 1339773
That is not a bug.  It is a database thing.  

Databases don't return position.  (Dbase are an exception to the rule)  Due to that fact, the scroll bar that is in the DBGrid can only know if it is at EOF, BOF, or not at either one.  That is why you get only 3 positions.  

Additionally, there is a way to do it but, filtering, ordering, or any of that will prevent the scroll bar from returning good data.  Eg.  In ordering you may be on the 3rd ordered record but that record may have record number 234--your scroll bar ends up at the bottom when you are on record 3 only.  It will only work with a TTable that is not ordered or filtered.  TQuery will not work and nothing but a DBASE file will work with the TTable.  

As you can see it is not a Borland bug, it is an Ashton-Tate bug (DBase was made by them) that Borland inherited when they bought them out.  I suggest not doing it at all due to the problems you will most likely run into.  If your tables are Indexed at all, forget the idea--your scroll bar will not show valid data anyway.  

The way to do it if you still persist, is to remove the TDBGird's verical scroll bar and place one of your own to do what you want.  Removing the TDBGrid's scrollbar runs into major problems too.  So you will probably spend a lot of time writing code that you will end of scraping in the end becuase you hate the way it ends up processing.  

Sorry to be so pessimistic but that is the scoop.  If you want to look for yourself, that question fills all the newsgroups.  Goto this site and type in "dbgrid scrollbar" and read about all the problems that arise from trying.

http://www.csd.net/~cgadd/del_srch.htm

Hope you have more progress that everyone else,
Scott
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 1

Expert Comment

by:millerw
ID: 1339774
Here is Borland's solution to removing the scroll bar that is there:
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.

Here is one that works with Paradox tables: (TScrollDBGrid)
http://www.teleport.com/~greglief/delphi.shtml

I've been continuing to look and I did find one on www.delphi32.com but everytime I try to download it, it says NotFound error.

I'll keep looking for you but I'm not sure how much help this will all be to you.  

By the way, that wasn't supposed to be an answer.  I clicked on the wrong radio box.  Reject it if you don't like it.

Scott
0
 
LVL 1

Expert Comment

by:millerw
ID: 1339775
Tried Borland's code and as I feared from reading the newsgroups, you get a flicker of the vert scrollbar with each move of the cursor.  Really sucks.  One suggestion is to make the dbgrid slightly bigger than your panel so that the panel's right edge covers up the scrollbar---sounded interesting.

www.woll2woll.com

That is the home of InfoPower components.  They of course aren't free but they do the scroll bar "correctly."  Check them out if you are still interested.  I personally don't believe in paying money for a bunch of components--I will only pay for source code but want the compiled version free.  

Scott
0
 

Author Comment

by:PhiNet
ID: 1339776
Hi Scott!

Your answer is fully correctly. Nevertheless, for my purpose  - using the program as a pure (read only) browser for dBase databases, I found a solution:

I had to add/change Borlands source-code slightly in a way that grids  actually use recordcount  for determing the position of the scrollbar..

If you are interested, I could the mods to you. But please be aware: As you mentioned: no filtering, no orders, that are not indexed.

0
 
LVL 1

Expert Comment

by:millerw
ID: 1339777
Sure, I'm always interested in components or source code.  I'd like to see what you have done.  I think it is probably what I have been thinking but, never know, may be something new that I don't know.  

If you can post it, I'd appreciate it.

Talk to you soon,
Scott
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This video discusses moving either the default database or any database to a new volume.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now