AutoFitColumns Property

Gets or sets whether columns are auto-sized to occupy all available horizontal space in the grid.

object.AutoFitColumns = [boolean]

Where object is an object expression that evaluates to one of the objects in the Applies To list, and boolean is a boolean expression that evaluates to either True or False, as described in Settings below.

Client support

   Newlook Smartclient

   Newlook Server

Use

The behavior of this property is dependent on whether the datagrid is automatically generated from a host subfile or an inserted datagrid bound to a data source.

Grids generated from host subfiles

When a subfile is received from the host, the Newlook recognition engine attempts to organize its data into columns. If columns can be clearly identified then the ShowColumns and AutoFitColumns properties default to True. This property will have no effect if ShowColumns is False.

When AutoFitColumns is set to True, columns will be automatically sized in the grid control so that they are spaced proportionally across the grid's available width.

Figure 1. An example grid with AutoFitColumns set to False.

Figure 2. The same grid with AutoFitColumns set to True.

Bound grids

The AutoFitColumns property works slightly different for bound grids. In this case, default column widths are determined by the length of the underlying database field. If columns extend past the visible area of the grid (i.e. the grid is horizontally scrollable) then setting the AutoFitColumns property to True will make no difference. If the columns, at their default width, fit within the visible area of the grid, then setting AutoFitColumns to True will extend the size the columns evenly within the available width of the grid.

BE AWARE THAT:

While the AutoFitColumns property is supported in both Newlook Smartclient and Newlook Server, the width of columns will not be identical, as the two clients use different algorithms to calculate the available space for columns.

Settings

Setting

Description

True

(Default) Automatically size all columns in the grid control so that they are spaced proportionally across the grid's available width.

False

Size grid columns according to the contents of the column.

See Also

ShowColumns property | ShowHorzScrollBar property

Applies To

DataGrid control