Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

TDBGrid Scrolling ??????

761 views
Skip to first unread message

Oliver Kessler

unread,
Jan 16, 2001, 3:12:29 AM1/16/01
to
Hi to all,

I have a TDBGrid with Option RowSelect = True.
The underlaying TTable has more columns than
could be displayed at once in the TDBGrid, soooo
the TDBGrid has a horizontal Scrollbar. That gives me
the opportunity to scroll to further columns, wich are not
displayed at the beginning.

Now ... .if I am scrolling to the very right end of the TDBGrid and
I am selecting another record, automatically
the view jumps back to the very left side of the TDBGrid.
Not very nice for the user.

Is there any way to avoid this.

Regards

Olly


Robert Cerny

unread,
Jan 16, 2001, 3:37:36 PM1/16/01
to
Yes. Disable option rowselect.
Bet you already knew this. There's no other way (not an easy one at least).
IHMO, this behaviour is a feature. I like it this way.

--
----------------------
Regards
Robert Cerny
Remove both qwe when replying
email: robert.q...@neosys.xrs.qwe.si

No questions via email, unless explicitly invited.
Oliver Kessler wrote in message <3a6402b9$1_2@dnews>...

Oliver Kessler

unread,
Jan 17, 2001, 2:05:37 AM1/17/01
to
Thx Robert for your response,

because we are deploying our app. to some hundreds of Customers,
we need the easiest way to guide a user through our app, always in
mind that probably also people w/ not much experience in using
computers are working w/ our app.
Herefor we are using a extra-form for editing, so the user is not able to
edit directly in the grid. To make sure that the user knows wich record
he's going to edit (before he opens the "Editform"), we extra enabled
"RowSelect". The indicator is not enough for us.

Maybe some people will say that our "user-guiding" reminds to older
applications. Of course technics goes on and good that we have many
more choices than years ago and Innovations are important, but I will
show a small example, wich makes me mad any time I am going to drink
a glass of Orange-juice.

Some years ago the juice-packages (made of carton) were nearly perfect
(easy to open w/o any tools, only one material, etc.).
But "Innovations" were preached everywhere.

modern Juice-packages now:
- hard to open without a scissor.
- a short while ago it was even still hard to fill a glass w/o
dropping some juice besides the glass (but thanks, now
they developed a small plastic-tool, wich helps now).
and i gess in some more month or years it works as fine as ...
... it was some years ago (wich has been already approved).
(that is here in Germany so, maybe not in different countries).

... and of course there are some people saying, that the new packages
are better.

I just needed to express that, because my 15 years experience in
developing software telling me, that is very confusing, when I am
scolling to the very right side of a grid and I am changing than a
record, that the view jumps back to the very left side of the grid.
For my personally understanding that is not a behavior, it is an error.

But anyway thanks again for your response.

Olly

Robert Cerny <robert.q...@neosys.xrs.qwe.si> schrieb in im Newsbeitrag:
942erb...@neosys.xrs.si...

Guido Geurts

unread,
Jan 17, 2001, 8:51:56 AM1/17/01
to
You could set RowSelect to false, and simulate it in the onDrawCell
event...
That way you will keep the whole row colored, and keep the ability to
move to the right with the keyboard.
Guido.Geurts.vcf

Oliver Kessler

unread,
Jan 17, 2001, 11:38:52 AM1/17/01
to
Guido, Guido, Guido, my savior

that was a great idea !!

A thousand thx


Olly


Guido Geurts <Guido....@adtechno.be> schrieb in im Newsbeitrag:
3A65A37C...@adtechno.be...

Robert Cerny

unread,
Jan 20, 2001, 12:14:56 PM1/20/01
to
Don't get me wrong. I use the same design. However, in a grid I assume the
"most important" columns are listed first, so if the user scrolls right, he
doesn't see them and when scrolls up/down, sees them again, just to be sure
to pick the correct record. That's why I wrote that it's a good behaviour.

Sometimes this is either annoying, or want to give the user a chance to edit
directly in grid, so you have to turn off rowselect.
For this purpose I use two dbgrids linked to same datasource and divided by
splitter. Left grid has rowselect=true, right not. This looks like one grid
with one or more (possibly user selectable) fixed columns.


--
----------------------
Regards
Robert Cerny
Remove both qwe when replying
email: robert.q...@neosys.xrs.qwe.si

No questions via email, unless explicitly invited.

Oliver Kessler wrote in message <3a65448f_2@dnews>...

Bart Huls

unread,
Feb 2, 2001, 6:44:34 AM2/2/01
to
Hi Guide,

I have the same problem as decribed below (only in C++ Builder).
You have given a solution. Is it possible that you send me
a sample of the code?

Regards,

Bart Huls

>I have a TDBGrid with Option RowSelect = True.
>The underlaying TTable has more columns than
>could be displayed at once in the TDBGrid, soooo
>the TDBGrid has a horizontal Scrollbar. That gives me
>the opportunity to scroll to further columns, wich are not

>displayed at the beginning..


>
>Now ... .if I am scrolling to the very right end of the TDBGrid and
> I am selecting another record, automatically
>the view jumps back to the very left side of the TDBGrid.
>Not very nice for the user.
>
>Is there any way to avoid this.

> ---------------------------------------------------------------
>
> Name: Guido.Geurts.vcf
> Part 1.2 Type: text/x-vcard
> Encoding: 7bit
> Description: Card for Guido Geurts

Guido Geurts

unread,
Feb 2, 2001, 7:56:36 AM2/2/01
to
Bart Huls wrote:
>
> Hi Guide,
>
> I have the same problem as decribed below (only in C++ Builder).
> You have given a solution. Is it possible that you send me
> a sample of the code?
>
> Regards,


Well, C++Builder is new to me, but I managed to convert my pascal code
to it.
I tested it with a DBGrid, a datasource and a Table on a form.
The table has the database property set to DBDemos, and TableName =
Customer...

I did not succeeded in getting the "with do" syntax correct, so I put
it in comment,
also, "DBGrid1" should be a typecast from Sender, in Delphi that is
"TDBGrid(Sender)" but CBuilder did not seem to like that...

Anyway, I tested it, and it worked...

TForm1 *Form1;
long KeyFieldValue;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Table1AfterScroll(TDataSet *DataSet)
{
KeyFieldValue = Table1->FieldByName("CustNo")->AsInteger;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::DBGrid1DrawDataCell(TObject *Sender,
const TRect &Rect, TField *Field, TGridDrawState State)
{
// with TDBGrid(Sender) do
// {
// with Canvas do
// {
//You will have to know wich column holds the key field(s)...
if (DBGrid1->Columns->Items[0]->Field->AsInteger ==
KeyFieldValue)
{
DBGrid1->Canvas->Brush->Color = clNavy;
DBGrid1->Canvas->Font->Color = clWhite;
}
else
{
DBGrid1->Canvas->Brush->Color = clWhite;
DBGrid1->Canvas->Font->Color = clBlack;
};
// };
DBGrid1->DefaultDrawDataCell(Rect, Field, State);
// };

}

Guido.Geurts.vcf

Bart Huls

unread,
Feb 6, 2001, 4:16:48 AM2/6/01
to
Hi Guido,

It looks like to work, but now i have an other problem.
I'm setting FixedCols = 1 so that the left column stays on this
position. When I now click on this column, the column is duplicated
and show twice...


Regards,

Bart Huls

Guido Geurts

unread,
Feb 16, 2001, 9:06:13 AM2/16/01
to
Bart, FixedCols is a property meant for the StringGrid, and will not
work correctly on a TDBGrid.
I am afraid your only option is to fake it in the onDrawCell event as
well...
Guido.Geurts.vcf
0 new messages