If this is a data bound grid try:
grid.Model.Cols.Size[col] = 200;
> How do I explicitly set the column width for a grid with mulitple column rows.
> If I use the grid.Model.ColWidths it does not change.
AdministratorFebruary 7, 2003 05:51 PM UTC
grid.Model.ColWidths should work. You just have to be aware that the row header in the second and third rows are sharing the same columns as the first row.
Also, getting the column index that is associated with a field number within the table is a bit more complicate. The column index that is associated with a that fieldNum needs to be determined with code as follows
GridBoundRecordState state = Binder.GetRecordStateAtRowIndex(rowIndex);
GridHierarchyLevel ghl = Binder.levels[state.level] as GridHierarchyLevel;
int rowFieldNum = ghl.RowFieldToField(state.row, fieldNum);
int colIndex = this.binder.FieldToColIndex(rowFieldNum);
Now you can change the column width for the specified field.
We will try to make such things easier in future versions ...