Version

Auto-Sizing Columns and Rows

The WinGrid™ has the ability to auto sizing the columns and rows based on the setting of the AutoFitStyle property.

Auto-fitting columns to WinGrid’s width

  1. Before you start writing any code, you should place using/imports directives in your code-behind so you don’t need to always type out a member’s fully qualified name.

In Visual Basic:

Imports Infragistics.Win.UltraWinGrid

In C#:

using Infragistics.Win.UltraWinGrid;
  1. To automatically resize columns so they fit the width of the WinGrid set the AutoFitStyle property to ResizeAllColumns . This will make each column proportionally bigger or smaller so they all fit the WinGrid and eliminate the need for having a horizontal scrollbar. Also as the user resizes WinGrid, the columns will be continuously auto-resized to fit the WinGrid.

In Visual Basic:

Me.ultraGrid1.DisplayLayout.AutoFitStyle = AutoFitStyle.ResizeAllColumns

In C#:

this.ultraGrid1.DisplayLayout.AutoFitStyle = AutoFitStyle.ResizeAllColumns;
auto sizing ultragrid columns and rows
  1. You can exempt a specific column from automatically resizing by doing the following:

When Row-Layout mode is disabled - Set the LockedWidth to true. **

When Row-Layout mode is enabled - Set the WeightX of all the columns that you want to resize to auto-fit to a non-zero value and leave the WeightX of the column(s) that you want to exempt from resizing.

Related Topics