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

# TCustomDBGrid.UpdateAutoSizeColumns

Calculates the width for auto-sized columns and refreshes the grid control.

## Declaration

Source position: dbgrids.pas line 505

`protected procedure TCustomDBGrid.UpdateAutoSizeColumns;`

## Description

UpdateAutoSizeColumns is a method used to auto-size columns in the grid and redraw the control. No actions are performed in the method if gsAutoSized is already present in the GridStatus property. This occurs when UpdateAutoSizeColumns has already been called, and the columns have already been resized.

UpdateAutoSizeColumns visits each of the non-fixed Columns on the grid control. It uses both the TField and TGridColumn definitions for each column to determine its size. The TGridColumn instance in Columns provides the title and font used to measure the column header. The TField instance in the column definition provides the value for the field and its storage size when the data link is active for the control.

A temporary TCanvas instance is used to calculate the width for the text displayed in each of the columns.

UpdateAutoSizeColumns includes the value gsAutoSized in the GridStatus property when the resizing operation has been completed. The control is refreshed prior to exiting from the method.

## See also

TCustomDBGrid.GridStatus |  | Stores status information about operations active for the grid control.
TCustomDBGrid.Columns |  | Columns provides access to columns defined for the database grid control.
TCustomDBGrid.DataLink |  | Datalink for the component with event handlers for the linked dataset.
TGridColumn