Skip to main content
A newer version of this page is available. .

BaseControl.AutoSizeInLayoutControl Property

When a control is added to a LayoutControl, this property specifies whether the control’s width is changed to display its content in its entirety. This member is supported by individual descendant of the BaseControl class.

Namespace: DevExpress.XtraEditors

Assembly: DevExpress.XtraEditors.v18.2.dll

Declaration

[DXCategory("Properties")]
[Browsable(false)]
public virtual bool AutoSizeInLayoutControl { get; set; }

Property Value

Type Description
Boolean

true if auto-size mode is enabled; otherwise, false.

Remarks

Not all descendants of the BaseControl class support the auto-size feature within a LayoutControl.

See Aligning Controls Within Layout Items to learn more.

Example

The following code shows how to enable the auto-size feature for a CheckEdit within a LayoutControl, and center the CheckEdit within the corresponding layout item.

The auto-size feature is enabled for the CheckEdit control using its BaseCheckEdit.AutoSizeInLayoutControl property. In this mode, the control’s size shrinks to fit its content. This allows the control to be custom aligned within the layout item, using the LayoutControlItem.SizeConstraintsType and LayoutControlItem.ControlAlignment properties.

The image below shows the design-time result of the customization. The layout item in which the checkEdit1 control resides is highlighted in blue. The bounds of the checkEdit1 control are indicated by the rectangle at the center of the layout item:

LayoutControl_CheckEdit_AlignHorz

using DevExpress.XtraLayout;

checkEdit1.AutoSizeInLayoutControl = true;
layoutControlItem2.SizeConstraintsType = SizeConstraintsType.SupportHorzAlignment;
layoutControlItem2.ControlAlignment = ContentAlignment.TopCenter;
See Also