문제

Guys by specifying the column index,It is possible to set the autoresize property of that column. Like,

 gridview.AutoResizeColumn(1);

Is there any way to set this property to the datagridview without having to specify the columns indexes ?

도움이 되었습니까?

다른 팁

i would suggest you to set that value at creation time like :

Column myColumn = new Column() { AutoResizeColumn = true };

And then add this column to the column list of your gridview

on another hand you can do a "for each" loop to loop all the columns and give them the appropriate param value :

for each (Column col in gridview.Columns) {
    col.AutoResizeColumn = true;
}

but doing this at initialisation is probably a much stable approach (like having a column template object) and if you need to change value then you call by index this way is suppose :

gridview.Columns[index].AutoResizeColumn = false //as you wish
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top