DataGrid Autoformat Column Width?

  • Thread starter Thread starter WillieJoe
  • Start date Start date
W

WillieJoe

Good Morning,

Is there any way the Datagrid can be set to "autoformat"
the width of each column to the largest row entry.

If so - is this dynamic at runtime (meaning if a new row
is added by a user with a larger column width, the column
width is automatically increased)?

Seems like by default, each column width is the width of
the datagrid/# of columns.

Any help would be greatly appreciated (pretty new at
this!!)

Thanks again,
Willie
 
There is no automatic formatting, all columns are created equal. You can
create a custom GridStyle which sets up the widths.
http://www.inthehand.com/forums/viewtopic.php?t=96

There is no direct way to determine the longest string value, but you could
use System.Drawing.Graphics.MeasureString to determine the length in pixels
of a specific piece of text and use this to set the column width.

Peter

--
Peter Foot
Windows Embedded MVP

In The Hand
http://www.inthehand.com
 
Back
Top