Version

Modify Field-Sizing Behaviors

Your end users can double click a field’s resizing indicator to resize a field to fit the longest content in the field. When your end users automatically resize a field, the DataPresenter control will resize the field based on several factors. The first factor is the elements the DataPresenter control will measure, e.g., data cells, labels, summary cells, etc. and the second factor is whether these elements are in view. By default, the DataPresenter control will account for any elements in view when your end users automatically resize a field. However, you can modify this default behavior by setting the FieldSettings object’s AutoSizeOptions and AutoSizeScope properties.

You can set the AutoSizeOptions property to a bitwise combination of FieldAutoSizeOptions enum values. This property determines the elements that a DataPresenter control will measure. For example, if you set the AutoSizeOptions property to DataCells, the DataPresenter control will only measure data cells when resizing the field even if there are other elements such as labels or filter cells in view.

The AutoSizeScope property determines whether a DataPresenter control measures elements that are not in view. However, when your end users double click a field’s resizing indicator to resize the field, the DataPresenter control will have to allocate records in order to measure elements that are not in view. You should keep in mind that measuring elements in a DataPresenter control is time consuming; therefore, you should not use the ViewableRecords and AllRecords enum values when dealing with large data sources.

The following example code demonstrates how to modify field-sizing behaviors.

In XAML:

<igDP:XamDataPresenter Name="xamDataPresenter1" BindToSampleData="True">
    <igDP:XamDataPresenter.FieldSettings>
        <igDP:FieldSettings AutoSizeOptions="DataCells, Label" AutoSizeScope="ViewableRecords" />
    </igDP:XamDataPresenter.FieldSettings>
</igDP:XamDataPresenter>

In Visual Basic:

Imports Infragistics.Windows.DataPresenter
...
Me.xamDataPresenter1.FieldSettings.AutoSizeOptions = FieldAutoSizeOptions.DataCells Or FieldAutoSizeOptions.Label
Me.xamDataPresenter1.FieldSettings.AutoSizeScope = FieldAutoSizeScope.ViewableRecords
...

In C#:

using Infragistics.Windows.DataPresenter;
...
this.xamDataPresenter1.FieldSettings.AutoSizeOptions = FieldAutoSizeOptions.DataCells | FieldAutoSizeOptions.Label;
this.xamDataPresenter1.FieldSettings.AutoSizeScope = FieldAutoSizeScope.ViewableRecords;
...