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

Auto-sizing DataGrid columns

17 views
Skip to first unread message

Ron Wickert

unread,
Nov 24, 1998, 3:00:00 AM11/24/98
to
Hi all:
Is there a way to get the columns in a datagrid to automatically size
themselves to the width of the displayed data, and if so, how is that
done?
In other words I'd like the columns to "shrink/stretch" to be whatever
size the longest field in that column happens to be.
I have a datagrid bound to an ADODC pulling records from Access 97. I
know I could just set each column width equal to whatever the Access
table defines as length, but I was wondering if there were a way to size
the columns "dynamically."
I've looked in the VB6 (so-called) HELP file but the info there wasn't
much help (SURPRISE!).
Appreciate any info anyone can provide. Thanks!

Darshan Desai

unread,
Nov 25, 1998, 3:00:00 AM11/25/98
to
Hi Ron,

If you set the 'DefColWidth' property of 'DBGRID' to 0, the control
automatically sizes all columns based on either the width of the column
heading or the Size property setting of the underlying field, whichever is
larger.


Greetings..

Darshan Desai
Tecnimont ICB Limited
Bombay, India.
darsha...@usa.net or
dar...@ticb.com


Ron Wickert wrote in message <365B374F...@worldnet.att.net>...

Ladislav Sedivy

unread,
Nov 27, 1998, 3:00:00 AM11/27/98
to
Darshan Desai wrote:
>
> Hi Ron,
>
> If you set the 'DefColWidth' property of 'DBGRID' to 0, the control
> automatically sizes all columns based on either the width of the column
> heading or the Size property setting of the underlying field, whichever is
> larger.

Yes, this is correct. However, for text/memo fields the data control
always reports the max. width (number of characters). Since it would be
ridiculous for the grid to set the width of a column to this value, the
grid just sets it to approx. 20 characters. True DBGrid Pro 6.0 will
autosize the width of a column when you double-click on a columns
header.

Lac

0 new messages