Sign in Join
FPDoc Onlineexperiment

TCustomDrawGrid.AutoFillColumns property

Member of TCustomDrawGridpublicIn unit Grids

Indicates whether columns are automatically resized to fill the visible area in the grid.

Declaration

pascal
property AutoFillColumns:;

Description

AutoFillColumns is a Boolean property which enables or disables automatic sizing for columns on the grid control. The default value for the property is False, and indicates that automatic column sizing is not enabled.

Changing AutoFillColumns to True causes the column sizes to be recalculated (and cached) based on default values, or using properties assigned to the TGridColumn instances when the Columns collection has been Enabled. The resizing algorithm works as follows:

  • Fixed columns are not resized.
  • When Columns has not been Enabled, or the column position is not found in Columns, a default sizing priority of 1 is used along with the minimum and maximum sizes defined in the DEFMINSIZE and DEFMAXSIZE constants.
  • When Columns is Enabled, and a column is defined for a given position, values from the TGridColumn instance are used including: SizePriority, MinSize, and MaxSize.
  • A column with a SizePriority of 0 is not resized.
  • A column with a non-zero value in SizePriority is adjusted using the average available width with respect to the MinSize and MaxSize for all of the defined columns. When MinSize and MaxSize have the same non-zero value, the column cannot be resized. If all columns have assigned MinSize and MaxSize values, the auto-fill algorithm may not be able to set column widths as intended. At least one of the columns should have MinSize and MaxSize set to 0 for the intended result.
  • If Columns is not Enabled (populated), fixed columns are set to the size found in either ColWidths (preferred) or DefaultColWidth (default). Non-fixed columns (starting at FixedCols-1) are uniformly resized to fill the available unused area following the fixed columns.

Please note that TGridColumn instances in Columns are initially created with SizePriority set to 1. For TDbGrid, which automatically populates Columns, this means the user will not be able to resize these columns using the mouse (since they are auto-sized).

Use ColWidths to set the width for a specified column when the Columns collection has not been enabled or populated. Use DefaultColWidth to set the default width used when a width is not available in ColWidths or Columns.

This description is the one of Grids.TCustomGrid.AutoFillColumns.

See also

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.