Solved

Scrollbar in DBGrid (Delphi 3)

Posted on 1997-07-25
8
3,007 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
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
 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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 video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

792 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