DataGrid Autoformat Column Width?

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
 
P

Peter Foot [MVP]

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top