Infragistics(R) NetAdvantage(R) Windows Forms
AutoFitStyle Property
See Also  Example E-mail your feedback on this topic.
Infragistics.Win.UltraWinGrid Namespace > UltraGridLayout Class : 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.


Visual Basic (Declaration) 
Public Property AutoFitStyle As AutoFitStyle
public AutoFitStyle AutoFitStyle {get; set;}


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.

Visual BasicCopy Code
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
C#Copy Code
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;



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 UltraDropDownBase.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.

See Also