Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
135
Change Field width
posted

I implement fields auto-size logic. When desired width calculated, it's applied for field:

field.Settings.CellWidth = field.Settings.LabelWidth = width;

This code works perfect when for examle underlying data changed. But when user manualy change field width of the column,  below code stop works for this column. How invalidate actual field width, so that grid will get it from field.Settings.CellWidth and field.Settings.LabelWidth?

Try next hack, but this not help:

PropertyInfo columnWidthVersionPropertyInfo = typeof(FieldLayout).GetProperty("GridColumnWidthVersion", BindingFlags.Instance | BindingFlags.NonPublic);
int version = (int)columnWidthVersionPropertyInfo.GetValue(fieldLayout, new object[{});
columnWidthVersionPropertyInfo.SetValue(fieldLayout, version+1, new object[{});