static DataGrid column width in C# in visual studio 2010
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;
}
精彩评论