Version

AutoFitStyle Property

Specifies whether the AutoFitColumns feature is enabled. This feature automatically resizes the column widths proportionally to fit the visible area of the grid.
Syntax
'Declaration
 
Public Property AutoFitStyle As AutoFitStyle
public AutoFitStyle AutoFitStyle {get; set;}
Remarks

When AutoFitStyle is set to ResizeAllColumns, UltraGrid automatically resizes columns in a band to fit within the visible area of the grid.

When AutoFitStyle is set to ExtendLastColumn, UltraGrid automatically resizes the last column to fit within the visible area of the grid.

In Row-Layout mode if you enable this functionality and then disable it the widths of the columns will be restored to their previous settings. In non non-row-layout mode however this is not the case. In non-row-layout mode if you set the property to ResizeAllColumns and reset it back to None the UltraGrid will not restore the columns to their previous widths. The internally stored column width is altered by setting this property; if you wish to restore column widths after changing the setting of AutoFitStyle then you must write code to store and re-apply the widths.

For UltraDropDown and UltraCombo this feature auto-fits the columns to DropDownWidth setting. If the DropDownWidth is set to -1 or 0 then the columns are resized to fit the width of the UltraDropDown or the UltraCombo control.

Note that this is different from having the column resize itself to ensure that all the cell contents are fully visible. For that feature use the UltraGridColumn.PerformAutoResize method.

Example
Following code sets AutoFitStyle to ResizeAllColumns to make the UltraWinGrid resize all the columns so all of them fit in the available width, thus eliminating the need for a horizontal scroll bar. It affects all the bands.

Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinGrid

  Private Sub Button19_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button19.Click

      Me.UltraGrid1.DisplayLayout.AutoFitStyle = AutoFitStyle.ResizeAllColumns

  End Sub
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
using System.Diagnostics;

private void button19_Click(object sender, System.EventArgs e)
{

	this.UltraGrid1.DisplayLayout.AutoFitStyle = AutoFitStyle.ResizeAllColumns;

}
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, 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

See Also