ColumnDefinition.SizeType Property

Gets or sets the column's size type in a table layout.

Namespace: DevExpress.XtraLayout

Assembly: DevExpress.XtraLayout.v20.2.dll

Declaration

[XtraSerializableProperty]
public SizeType SizeType { get; set; }
<XtraSerializableProperty>
Public Property SizeType As SizeType

Property Value

Type Description
SizeType

A value that specifies the column's size type.

Remarks

In a table layout, a group's width is distributed among columns according to their size types. Columns support three size types:

  • Absolute - The column has a fixed width specified by the ColumnDefinition.Width property, whose value is the number of pixels.
  • Percent - The column occupies a certain percentage of the total group width. The ColumnDefinition.Width property value is the percentage value. When a layout is resized, columns of the Percent type are resized accordingly.
  • AutoSize - The column width is automatically adjusted to best fit the column's contents. The ColumnDefinition.Width property is ignored.

A table layout may contain rows and columns of different size types simultaneously. In this case, available space is distributed between rows and columns in the following order:

  • First of all, space is allocated for rows/columns of the Absolute type.
  • Second, space is allocated for rows/columns of the AutoSize type.
  • Finally, the remaining space is distributed among rows/columns of the Percent type.

By default, after enabling table layout mode, two columns are automatically created. Their SizeType properties are set to Percent, and the Width properties are set to 50, so they share the table layout equally. If you then add a new column at design time or append a new column with the default settings in code, the new column's width type will be AutoSize.

Percent Columns/Rows

Each time a column/row of the Percent size type is added to the table layout, or the size is changed for an existing Percent column/row, the Layout Control recalculates the sizes (ColumnDefinition.Width or RowDefinition.Height) of all existing Percent items, so that their sum equals to 100%, while keeping the proportions between the affected items.

Consider a table layout that contains two Percent columns whose widths are 40% and 60% respectively.

LayoutControl-TableLayout-PercentColumns-Initial

When you add another Percent column with the width equal to 80%, the widths of all the three columns will be automatically recalculated according to the expressions:

New width of column 1 = 40%*100% / (40% + 60% + 80%) = 22.222...% New width of column 2 = 60%*100% / (40% + 60% + 80%) = 33.333...% New width of column 3 = 80%*100% / (40% + 60% + 80%) = 44.444...%

LayoutControl-TableLayout-PercentColumns-AfterAdding80Percent

In the case of multiple column modifications, you may want to avoid width recalculation of Percent columns/rows until all the modifications are made. To accomplish this, wrap the modification code in the LayoutControl.BeginUpdate and LayoutControl.EndUpdate method calls.

See Also