开发者

static DataGrid column width in C# in visual studio 2010

开发者 https://www.devze.com 2023-03-29 08:33 出处:网络
I tried doing for (int x = 0; x < gridQuestion.Columns.Count; x++) { gridQuestion.Columns[x].ItemStyle.Width = 50;

I tried doing

for (int x = 0; x < gridQuestion.Columns.Count; x++)
{
    gridQuestion.Columns[x].ItemStyle.Width = 50;
}

but 开发者_StackOverflow社区the columns still go across the page (not wrapping).

It should wrap if I get it right yes?


Try the Wrap property of the ItemStyle (though it should be true by default):

for (int x = 0; x < gridQuestion.Columns.Count; x++)
{
    gridQuestion.Columns[x].HeaderStyle.Width = 50;
    gridQuestion.Columns[x].ItemStyle.Width = 50;
    gridQuestion.Columns[x].ItemStyle.Wrap = true;
}
0

精彩评论

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