[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] Reference for unit 'Grids' (#lcl)

TCustomStringGrid.AutoAdjustColumn

Adjusts the column size for the font, text length, and images used in the specified column.

Declaration

Source position: grids.pas line 1768

protected procedure TCustomStringGrid.AutoAdjustColumn(

  aCol: Integer

); override;

Arguments

aCol

  

Column number for values examined in the method.

Description

Adjusts the column specified in ACol to use the width needed for the font and image(s) for the column. No actions are performed in the method when ACol is not a valid column index.

AutoAdjustColumn calculates the width need for the image (if any) used in the column header, and adds the padding specified in the DEFIMAGEPADDING constant. If a sort indicator is used, the same actions are performed for the sort image. The image widths may be scaled to the current display density if the PPI for the control Font differs from the value in TitleImageList.

AutoAdjustColumn visits the rows in the grid to calculate the maximum width required for the text in each. A temporary Canvas instance is used to calculate the width for the text. When Columns has been enabled, fonts assigned to the TGridColumn instance are used. When Columns has not been enabled, TitleFont is used for fixed rows or columns. Otherwise, the Font for the grid is used.

For multi-line columns, the DrawText routine is called to calculate the text rectangle. For single-line columns, the TextExtent method in the canvas is used. Cell padding is added to the calculated column width using the value in varCellPadding. The derived column width is stored in the ColWidths property for the column specified in ACol.

AutoAdjustColumn is called from the DblClick method when column auto-sizing and double click auto-sizing have been enabled in the Options for the grid. It is also called from the AutoAdjustColumns, AutoSizeColumns, and AutoSizeColumn methods.

See also

TCustomGrid.AutoAdjustColumn

  

Adjusts column properties to accommodate the largest value in the specified column.

TCustomGrid.IsColumnIndexValid

  

Indicates if the specified index position is valid for the columns in the grid.


Version 3.2 Generated 2024-02-25 Home