Sign in Join
FPDoc Onlineexperiment

TCustomDBGrid.UpdateAutoSizeColumns procedure

Member of TCustomDBGridprotectedIn unit DBGrids

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

Declaration

pascal
procedure 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

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