🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.delphi.database.win32
2 messages
2 total messages Started by Scott Leake Fri, 07 Mar 2008 01:53
TDBGrid - how to control scrolling?
#166
Author: Scott Leake
Date: Fri, 07 Mar 2008 01:53
28 lines
2112 bytes
I have a TBGrid that uses a DataSource hooked to a TIBQuery. How do I
control the scrolling that goes on?

Here is my issue: Let's say there are 50 rows and the size of the grid
displays 10 of them. The user can use the scroll bars to scroll no problem.
But, there are times where I need to automatically position which row is
selected based on something the user does. When they perform their action, I
do:

Tquery.DisableControls;
CurrPos := Tquery.GetBookmark;
If not Locate(<value>, <field>, []) then
  Tquery.GotoBookmark(CurrPos);
Tquery.EnableControls;

When I do this, it goes where I want it, but the selected row seems to jump
all around. Sometimes it is the first, others somewhere in the middle and
other times at the bottom. And there is no rhyme or reason to it and it just
seems to jump around. If I do this several times in a row quickly, it looks
like something is wrong.

What I would love to do is have the highlighted/selected row be say the
fourth row and have the data behind it move but not the selected row to give
a more consistent look to the user.  Is this possible?

Thanks!

Scott
Re: TDBGrid - how to control scrolling?
#176
Author: yannis
Date: Fri, 21 Mar 2008 14:00
45 lines
2677 bytes
Scott Leake brought next idea :
> I have a TBGrid that uses a DataSource hooked to a TIBQuery. How do I
> control the scrolling that goes on?
>
> Here is my issue: Let's say there are 50 rows and the size of the grid
> displays 10 of them. The user can use the scroll bars to scroll no problem.
> But, there are times where I need to automatically position which row is
> selected based on something the user does. When they perform their action, I
> do:
>
> Tquery.DisableControls;
> CurrPos := Tquery.GetBookmark;
> If not Locate(<value>, <field>, []) then
>   Tquery.GotoBookmark(CurrPos);
> Tquery.EnableControls;
>
> When I do this, it goes where I want it, but the selected row seems to jump
> all around. Sometimes it is the first, others somewhere in the middle and
> other times at the bottom. And there is no rhyme or reason to it and it just
> seems to jump around. If I do this several times in a row quickly, it looks
> like something is wrong.
>
> What I would love to do is have the highlighted/selected row be say the
> fourth row and have the data behind it move but not the selected row to give
> a more consistent look to the user.  Is this possible?
>
> Thanks!
>
> Scott

Well I do not thing that it is unexplainable how this work. The rule of 
thumb is simple. IF the record your are looking is bellow the current 
view then it will be the last raw on the view after selected, if it 
above it will be the first. It is possible to be in the middle if it is 
already in view. You can have a consistent effect if you move to the 
first record before using locate, I do not know if this is what you are 
after though.


regards
Yannis.

-- 
Do, or do not. There is no 'try'.
    - Yoda ('The Empire Strikes Back')
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads