Question

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 ?

Was it helpful?

OTHER TIPS

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top