Canvas Toolkit
← Class index

CFormLayout

Layouts · extends CLayout

Two-column layout for label/field forms, with support for spanning rows.

import { CFormLayout } from "canvas-toolkit-lib";

Declared members

addRow(labelText: string, field: CWidget): void;

Adds a row to the form. The row may consist of a generated text label and field, an explicit label widget and field, or a single widget spanning the whole row. Generated labels automatically use the field as their buddy. Explicit label widgets keep their existing buddy association.

addRow(label: CWidget, field: CWidget): void;
addRow(widget: CWidget): void;
insertRow(row: number, labelText: string, field: CWidget): void;

Inserts a row at the specified position.

insertRow(row: number, label: CWidget, field: CWidget): void;
insertRow(row: number, widget: CWidget): void;
rowCount(): number;

Returns the number of rows in the form.

removeRow(row: number): void;

Removes the row at the specified position.

labelForField(field: CWidget): CWidget | null;

Returns the label associated with a field widget.

labelColumnWidth(): number;

Returns the effective width of the label column.

setLabelColumnWidth(width: number | null): void;

Sets a fixed label-column width, or `null` for automatic sizing.

labelAlignment(): CAlignment;

Returns the alignment applied to label widgets.

setLabelAlignment(alignment: CAlignment): void;

Sets the alignment of all label widgets.

horizontalSpacing(): number;

Returns the horizontal spacing between labels and fields.

setHorizontalSpacing(spacing: number): void;

Sets the horizontal spacing between labels and fields.

verticalSpacing(): number;

Returns the vertical spacing between rows.

setVerticalSpacing(spacing: number): void;

Sets the vertical spacing between rows.

widgetAt(index: number): CWidget | null;

Returns a widget by flat index or by row and item role.

widgetAt(row: number, role: CFormLayoutItemRole): CWidget | null;
clear(): void;

Removes all rows and layout items.

stackBelowWidth(): number | null;

Returns the content width below which each label sits above its field.

setStackBelowWidth(width: number | null): void;

Sets the stacking threshold in content pixels, or null to keep two columns.

hasHeightForWidth(): boolean;
heightForWidth(width: number): number;
update(): void;

Recalculates and applies the geometry of all form rows.

sizeHint(): CSize;

Returns the preferred size required by the form.