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
1325
Setting Field.AutoSizeOptions doesn't take any effect
posted

Hi. I'm adding an UnboundField at the runtime by using this code:

UnboundField field = new UnboundField();
field.Name = "Field";
field.Label = "Field";
field.BindingPath = new PropertyPath("Property");
field.Settings.CellValuePresenterStyle = TryFindResource("FieldStyle") as Style;
field.Settings.AutoSizeOptions = FieldAutoSizeOptions.Label;
field.Settings.AutoSizeScope = FieldAutoSizeScope.AllRecords;

Field is added and successfully binded to the data, but it's not automatically resized. Am I doing something wrong?

Parents
  • 54937
    Verified Answer
    Offline posted

    The autosize settings are only used when using autosizing which means either when the Width property of the Field is set to InitialAuto/Auto or you double click the right edge. Note the settings you have don't really make sense to me. You have it set up such that the field will be autosized based on the width of the Label only (AutoSizeOptions is a flagged enum that by default will include everything) but then you have set the AutoSizeScope to AllRecords (which means the cells of all records and not just those in view should be considered) but since there are no cell related flags in the AutoSizeOptions that won't really mean anything because you only have it set to size to the label. Assuming you want it to consider the cells then you probably don't need to set the AutoSizeOptions. So just to summarize:

    • AutoSizeOptions is used to tell the grid what things should be measured when the field is autosized. The default is All.
    • AutoSizeScope is used to tell the grid which records should be measured when calculating the autosize. It has values of RecordsInView (i.e. just the elements you see on screen), ViewableRecords (every record associated with the field except filtered out/hidden records and children of collapsed records) and AllRecords (every record associated with the field). The latter 2 will force allocation of the records and will also have more of a performance overhead since it will mean the measurement of that many more elements. The default is RecordsInView.
    • Autosizing occurs when either you double click on the far edge of a field or when the Width property (either of the field or fieldsettings) is set to a FieldLength whose UnitType is either Auto or InitialAuto.
    • InitialAuto and Auto have different implications. Auto means that the field will calculate the size whenever the value of any cell (based on the AutoSizeScope) is changed. InitialAuto will do the autosize calculation once and then the result of that calculation is used as the field width and changes to the cells will not result in recalculations.

     

Reply Children
No Data