Programatically Set The Width of a column in a datagrid.

Programatically Set The Width of a column in a datagrid.

Post by UJ » Sun, 05 Feb 2006 06:08:33


How can I set the width of a column in a datagrid? I'm creating a new table,
defining the columns then tying it to a datagrid and want to make the column
wider than the default (the default value is cutting off some of a string.)

TIA - Jeff.
 
 
 

Programatically Set The Width of a column in a datagrid.

Post by netne » Sun, 05 Feb 2006 06:15:48

theBoundColumn.ItemStyle.Width = "500";

hope thats what your lookin for.



sean

 
 
 

Programatically Set The Width of a column in a datagrid.

Post by TWFyayBSLi » Sun, 05 Feb 2006 21:55:39

Hi UJ,
if you want to have the columns auto adjust instead of setting them to a
fixed width then you can set the DataGridViews AutoSizeColumnsMode. The
columns will then autosize depending on the size of the data in them.

Hope that helps
Mark Dawson
http://www.yqcomputer.com/