views:

101

answers:

2

i'm creating a user control in C# .net compact framework 3.5. And i'm using a DataGrid Control with a DataTable as the DataGrid's DataSource. i need to make some of the grid columns wider.

for some reason i can't...

i just couldn't find the method or property that controls the column width...

any ideas?

thanks in advance...

+1  A: 

You're looking for the AutoSizeMode and Width properties of the columns.

Bobby
that works only in a DataGridView by what i found
George
@OP: You should clearly tag/specify the technology you mean to avoid confusion. It takes a while to grok that you meant DataGrid, not DataGridView, and that you wrote DataSource, so it's not the WPF or Silverlight variant.
Alex Paven
@George: We're talking ASP.NET here? In that case forget what I said, yes.
Bobby
actually my bad it's in windows CE .net compact framework 3.5.and i'm creating a user control.
George
+1  A: 

sample code below -

foreach(DataGridColumnStyle vColumnStyle in myGrid.TableStyles[0].GridColumnStyles )
{
    if (vColumnStyle.HeaderText.ToLower()=="mycolumn")    
    {                
        vColumnStyle.Width = 60;            
    }
}
Sachin Shanbhag