TTMSFNCDataGridCore.StretchColumns Method
Resizes columns so that together they fill the available width.
API unit family: TMSFNCDataGridCore
Declaring type: TTMSFNCDataGridCore
Syntax
function StretchColumns(AMode: TTMSFNCDataGridStretchingMode = gstmAll; ARange: TTMSFNCDataGridStretchingRange = gstrNormal; AIndex: Integer = -1; ANewWidth: Double = -1): Boolean;
bool __fastcall StretchColumns(TTMSFNCDataGridStretchingMode AMode = (TTMSFNCDataGridStretchingMode)(0x1), TTMSFNCDataGridStretchingRange ARange = (TTMSFNCDataGridStretchingRange)(0x0), int AIndex = 0xffffffff, double ANewWidth = -1.000000E+00);
Remarks
The widths are assigned through ColumnWidths inside a BeginUpdate/EndUpdate pair, so they are stored as custom widths and the layout is recalculated once. Call it again after the control is resized, or enable the automatic stretching option of the grid instead.
Parameters
| Name | Description |
|---|---|
AMode |
How the space is divided: to one column (gstmIndex), equally (gstmAll, default), or in proportion to the current widths (gstmProportional). |
ARange |
With gstrNormal (default) only the scrollable columns are resized and the fixed left/right column widths are subtracted from the available width; with gstrAll the fixed columns are resized too. Hidden columns are always skipped. |
AIndex |
Column that receives the remaining width when AMode = gstmIndex; -1 (default) selects the last non-hidden column in the range. Ignored for the other modes. |
ANewWidth |
Total width to fill, in pixels; -1 (default) uses the width of the content rectangle of the control. |
Returns
True when new widths were applied; False when there is no non-hidden column in the range, the available width is negative, or (for gstmIndex) the target column is hidden, out of range or would get no positive width, in which case it is reset to DefaultColumnWidth.
Examples
// Proportionally stretch all columns to fill the grid width
Grid.StretchColumns(gstmProportional);