'Declaration Public Enum AutoFitMode Inherits System.Enum
public enum AutoFitMode : System.Enum
Member | Description |
---|---|
Always | The field layout is always in autofit mode and all fields are resized. |
Default | Defaults to ResizeAllFields when DataPresenterBase.AutoFit is true, to ResizeStarFields if DataPresenterBase.AutoFit is null and to None if DataPresenterBase.AutoFit is false. |
ExtendLastField | Only the fields in the last logical column are resized. For example, in a vertical orientation the right most fields are resized. |
Never | The fields are not automatically resized based on the viewable area of the DataPresenterBase |
OnlyWithVisibleStarFields | The field layout participates in autofit mode as long as there is one visible field with an explicit star extent. |
Imports Infragistics.Windows.DataPresenter Private Sub xamDataGrid1_Initialized(ByVal sender As System.Object, ByVal e As System.EventArgs) Me.InitializeControl(DirectCast(sender, XamDataGrid)) End Sub Private Sub InitializeControl(ByVal grid As XamDataGrid) Dim f As Field = Nothing ' You can control the default AutoFitMode for all FieldLayouts ' that haven't explicitly set their AutoFitMode by either ' setting it on the DP's FieldLayoutSettings. You can also ' set the previously existing AutoFit property on the ' DataPresenterBase. Dim flDefaultSettings As New FieldLayoutSettings() flDefaultSettings.AutoFitMode = AutoFitMode.Never flDefaultSettings.HeaderPrefixAreaDisplayMode = HeaderPrefixAreaDisplayMode.FieldChooserButton grid.FieldLayoutSettings = flDefaultSettings ' OnlyWithVisibleStarFields ' ========================= ' AutoFitMode of OnlyWithVisibleStarFields so as long as there are ' star fields visible, the fields will fill the available area. Dim flStar As New FieldLayout() flStar.Key = "HasStarFields" Dim flStarSettings As New FieldLayoutSettings() flStarSettings.AutoFitMode = AutoFitMode.OnlyWithVisibleStarFields flStar.Settings = flStarSettings f = New Field() f.Name = "name" flStar.Fields.Add(f) f = New Field() f.Name = "salary" flStar.Fields.Add(f) f = New Field() f.Name = "email" f.Width = New FieldLength(1, FieldLengthUnitType.Star) flStar.Fields.Add(f) f = New Field() f.Name = "department" f.Width = New FieldLength(2, FieldLengthUnitType.Star) flStar.Fields.Add(f) ' Always ' ====== ' AutoFitMode of Always means all visible fields are resized to fill the ' available area. The extent of fields may be increased or decreased. Dim flAlways As New FieldLayout() flAlways.Key = "Always" Dim flAlwaysSettings As New FieldLayoutSettings() flAlwaysSettings.AutoFitMode = AutoFitMode.Always flAlways.Settings = flAlwaysSettings f = New Field() f.Name = "name" flAlways.Fields.Add(f) f = New Field() f.Name = "salary" flAlways.Fields.Add(f) f = New Field() f.Name = "email" flAlways.Fields.Add(f) f = New Field() f.Name = "department" flAlways.Fields.Add(f) ' ExtendLastField ' =============== ' AutoFitMode of ExtendLastField is a little different than the ' other modes in that non-star fields will never be reduced. The ' preferred sizes of the fields is used and if there is extra ' space available the last field will be increased in width to ' fill the available area. Dim flExtend As New FieldLayout() flExtend.Key = "ExtendLastField" Dim flExtendSettings As New FieldLayoutSettings() flExtendSettings.AutoFitMode = AutoFitMode.ExtendLastField flExtend.Settings = flExtendSettings f = New Field() f.Name = "name" flExtend.Fields.Add(f) f = New Field() f.Name = "salary" flExtend.Fields.Add(f) f = New Field() f.Name = "email" flExtend.Fields.Add(f) f = New Field() f.Name = "department" flExtend.Fields.Add(f) ' Remove the key of one of these to use it in the sample ' e.g. 'flStar.Key = Nothing grid.FieldLayouts.Add(flStar) grid.FieldLayouts.Add(flAlways) grid.FieldLayouts.Add(flExtend) End Sub
using Infragistics.Windows.DataPresenter; private void xamDataGrid1_Initialized(object sender, EventArgs e) { this.InitializeControl(sender as XamDataGrid); } private void InitializeControl(XamDataGrid grid) { Field f = null; // You can control the default AutoFitMode for all FieldLayouts // that haven't explicitly set their AutoFitMode by either // setting it on the DP's FieldLayoutSettings. You can also // set the previously existing AutoFit property on the // DataPresenterBase. FieldLayoutSettings flDefaultSettings = new FieldLayoutSettings(); flDefaultSettings.AutoFitMode = AutoFitMode.Never; flDefaultSettings.HeaderPrefixAreaDisplayMode = HeaderPrefixAreaDisplayMode.FieldChooserButton; grid.FieldLayoutSettings = flDefaultSettings; // OnlyWithVisibleStarFields // ========================= // AutoFitMode of OnlyWithVisibleStarFields so as long as there are // star fields visible, the fields will fill the available area. FieldLayout flStar = new FieldLayout(); flStar.Key = "HasStarFields"; FieldLayoutSettings flStarSettings = new FieldLayoutSettings(); flStarSettings.AutoFitMode = AutoFitMode.OnlyWithVisibleStarFields; flStar.Settings = flStarSettings; f = new Field(); f.Name = "name"; flStar.Fields.Add(f); f = new Field(); f.Name = "salary"; flStar.Fields.Add(f); f = new Field(); f.Name = "email"; f.Width = new FieldLength(1, FieldLengthUnitType.Star); flStar.Fields.Add(f); f = new Field(); f.Name = "department"; f.Width = new FieldLength(2, FieldLengthUnitType.Star); flStar.Fields.Add(f); // Always // ====== // AutoFitMode of Always means all visible fields are resized to fill the // available area. The extent of fields may be increased or decreased. FieldLayout flAlways = new FieldLayout(); flAlways.Key = "Always"; FieldLayoutSettings flAlwaysSettings = new FieldLayoutSettings(); flAlwaysSettings.AutoFitMode = AutoFitMode.Always; flAlways.Settings = flAlwaysSettings; f = new Field(); f.Name = "name"; flAlways.Fields.Add(f); f = new Field(); f.Name = "salary"; flAlways.Fields.Add(f); f = new Field(); f.Name = "email"; flAlways.Fields.Add(f); f = new Field(); f.Name = "department"; flAlways.Fields.Add(f); // ExtendLastField // =============== // AutoFitMode of ExtendLastField is a little different than the // other modes in that non-star fields will never be reduced. The // preferred sizes of the fields is used and if there is extra // space available the last field will be increased in width to // fill the available area. FieldLayout flExtend = new FieldLayout(); flExtend.Key = "ExtendLastField"; FieldLayoutSettings flExtendSettings = new FieldLayoutSettings(); flExtendSettings.AutoFitMode = AutoFitMode.ExtendLastField; flExtend.Settings = flExtendSettings; f = new Field(); f.Name = "name"; flExtend.Fields.Add(f); f = new Field(); f.Name = "salary"; flExtend.Fields.Add(f); f = new Field(); f.Name = "email"; flExtend.Fields.Add(f); f = new Field(); f.Name = "department"; flExtend.Fields.Add(f); // Remove the key of one of these to use it in the sample // e.g. //flExtend.Key = null; grid.FieldLayouts.Add(flStar); grid.FieldLayouts.Add(flAlways); grid.FieldLayouts.Add(flExtend); }
Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2