Board index » delphi » DBGrids scrollbar problem

DBGrids scrollbar problem

Hi everybody,

I posted this one in the vcl.components.using group, but later I found out
that most messages about DBGrids are in this group, so here it is again:

Got a problem with the vertical scrollbar in DBGrids getting confused when I
use a TQuery with RequestLive=True and an  SQL-statement with the WHERE
clause including an AND.

Sample source code with the same topic as this one can be found in the
public.attachments newsgroup. As you will see, the problem already exist in
design mode. I'm using "Delphi Professional 5.0 (Build 6.18) Update Pack 1"
according to the About-box with BDE 5.1.1.

Anybody with an explanation/solution?

Sincerely Henning

 

Re:DBGrids scrollbar problem


Quote
>Got a problem with the vertical scrollbar in DBGrids getting confused when I
>use a TQuery with RequestLive=True and an

If you are referring to the scrollbar staying in the middle of the grid this is
just the way it works with some datasets.  It works this way when you have a
filter on a Paradox table and Request live is essentially a filter.

--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Re:DBGrids scrollbar problem


Hi Brian,

Thanks for your reply, but read on, please :-)

From your reply:

Quote
> If you are referring to the scrollbar staying in the middle of the
> grid this is just the way it works with some datasets.  It works
> this way when you have a  filter on a Paradox table and Request
> live is essentially a filter.

Yes, in this case it's in the middle, but it can just as well be at the
buttom, where it stays with no meaningfull use at all forcing the user to
use arrow/page keys to navigate the grid.

I have for some time now made a lot of experiments to figure out what
happens, and it looks like the the RecNo's from the "virtual" resultset of
the first condition in the WHERE clause stays in action throughout the
entire set of conditions. Example:

SELECT * FROM test WHERE field1="A" and field2="B"

The field1-condition alone results in a RecordCount of 1000 with RecNo 1 to
1000.
And field2 results in a RecordCount of 10 with perhaps RecNo=500 for the
first record with the scoll bar trying to posiotin itself to record 500 (the
RecNo) out of a RecordCount of 10.

A look in the DBGrids source in the UpdateScrollBar procedure has made this
sentence my prime suspect:

  if State in [dsInactive, dsBrowse, dsEdit] then
    SINew.nPos := RecNo;  // else keep old pos

If it "is just the way it works" I would call it a BUG effectively making
the DBgrids useless in real life applications. Shouldn't someone at Borland
do something about it, you think?

Sincerely Henning

Re:DBGrids scrollbar problem


On Wed, 28 Feb 2001 10:37:06 +0100, "Henning Schulz"

Quote
<udvikle...@hotmail.com> wrote:
>Got a problem with the vertical scrollbar in DBGrids getting confused when I
>use a TQuery with RequestLive=True and an  SQL-statement with the WHERE
>clause including an AND.

The problem is that a live query with a WHERE clause can be resolved
by placing either a range or a filter on the table.  When a filter is
applied, the Sequenced property of the TQuery should return False
because the Recno/RecordCount properties are not accurately
representing the record position in the dataset.  This is not the
case, so this can be called a (minor) bug.

Apart from not requesting a live query, there are two solutions:
1) add an index to resolve the WHERE clause
2) set the Filtered property of the TQuery to True
Mind, however, that solution 2 will show a non-proportional scrollbar.

HTH,

Jan

Re:DBGrids scrollbar problem


Hi Jan,

Thanks for your reply. As you can see in my reply to Brian my findings are
completely in line with yours.

Quote
> Mind, however, that solution 2 will show a non-proportional
> scrollbar.

Tried solution 2 (the easy one), it made the scollbar the infamous 3-state
type (top,middle,buttom) as you correctly states.

Well, I guess I'll just have to take another approach then.
Sincerely Henning

Re:DBGrids scrollbar problem


Quote
>If it "is just the way it works" I would call it a BUG effectively making
>the DBgrids useless in real life applications. Shouldn't someone at Borland
>do something about it, you think?

The DBGrid scrollbar works in many circumstances just not the ones you are
using.  There are may 3rd party grids you can switch to if you don't like the
one Borland provides.

--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Other Threads