How can I set the width of a column after my grid has already been loaded? (seems like such a simple task but I can't seem to get it...)Example: Program is running, user performs some action, I want to resize one or more columns.
Thank you,Mike
I would also like to know how to do this in code.
In my case, if the user has adjusted the column widths, I want to save the widths when the form is closing and set them the next time they open the form.
I have tryed setting the CellWidth and ColumnWidth but they don't seem to make any difference.
ron.
Looks like it is still not fixed in 10.1
Actually you wouldn't want to do that since you would essentially be telling the grid to ignore the size information that was just set, and AutoSize to the contents as if the end user double-clicked on the edge of a column.
Joe
Apparently, you may need to call fieldServant.PerformAutoSize() after setting width to actually change it.
Hi Ron -
Looking at your sample code, I think the problem is that you are using the CellWidth and LabelWidth properties on the Settings object as your source. The grid does not actually set these properties when the end user changes the width of a column - the properties on the Settings object are typically set by the developer to control behavior/appearance. You should instead be using the CellWidthResolved and LabelWidthResolved properties on the Field as the source like so:
fieldServant.Settings.CellWidth = fieldMaster.CellWidthResolved ;
fieldServant.Settings.LabelWidth = fieldMaster.LabelWidthResolved ;
Even better would be to change the target of the property setting to use the Field.Width property which is a little more efficient since a Settings object is not created and also more convenient since you don't have to set both Label AND Cell widths:
fieldServant.Width = new FieldLength(fieldMaster.CellWidthResolved, FieldLengthUnitType.Pixel);