How about datagrid1.Columns[0].Width
?
Look at this class. It has a width property that you can set.
EDIT: Look at this page. And look at the code under AddGridStyle
, which shows how to create the mapping & set each of the column style, width etc.
Hope that helps.
EDIT2: I am writing the following code without compiler (just using reflector & MSDN to look at the documentation). So, please be kind
DataGridTableStyle tableStyle = dataGrid1.TableStyles[0];
GridColumnStylesCollection colStyles = tableStyle.GridColumnStyles[0];
DataGridColumnStyle styleForCol1 = colStyles[0];
styleForCol1.Width = 165;
DataGridColumnStyle styleForCol2 = colStyles[1];
styleForCol1.Width = 125;
The code is derived from what I understood from this page under Remarks , which is quoted below
The System.Windows.Forms..::.DataGrid
control automatically creates a
collection of DataGridColumnStyle
objects for you when you set the
DataSource property to an appropriate
data source. The objects created
actually are instances of one of the
following classes that inherit from
DataGridColumnStyle:
DataGridBoolColumn or
DataGridTextBoxColumn class.