开发者

How do i change the column width of a DataGrid

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 ju开发者_Python百科st couldn't find the method or property that controls the column width...

any ideas?

thanks in advance...


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


sample code below -

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜