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

Custom Size Constraints

  • 3 minutes to read

By default, a layout item’s size is limited by the default size constraints, which are dependant upon the type of control displayed within the layout item. This topic describes how to override the default size constraints by imposing custom size limitations. To learn about the default size constraints, refer to the Default Size Constraints topic.

Custom Size Constraints

To provide custom size constraints for a layout item and its client area, set the LayoutControlItem.SizeConstraintsType property to SizeConstraintsType.Custom. Custom size constraints can be set for a layout item via the LayoutControlItem.MinSize and LayoutControlItem.MaxSize properties, or for the layout item’s client area via the LayoutControlItem.ControlMinSize and LayoutControlItem.ControlMaxSize properties.

The LayoutControlItem.MinSize and LayoutControlItem.ControlMinSize properties and the LayoutControlItem.MaxSize and LayoutControlItem.ControlMaxSize properties are synchronized. See Layout Item’s Size Constraints vs. Client Area’s Size Constraints to learn more.

If the Width or Height field of the MaxSize or ControlMaxSize properties is set to 0, the width/height of this layout item is not limited.

In default size constraints mode, the control always fills the layout item’s client area in its entirety. In custom size constraints mode, the control also fills the client area by default. However, in this mode it’s possible to make the control occupy only a portion of the client area and custom align the control within the layout item (for instance, center the control horizontally or vertically). To make the control not fill the client area entirely, apply size constraints to the control via the MaximumSize and MinimumSize properties. If the control’s size is less then the client area, it can be custom aligned within the client area via the LayoutControlItem.ControlAlignment property. See Aligning Controls Within Layout Items for more information.

Customizing Size Constraints via the Menu

The Layout Control’s Context Menu contains specific commands that affect the size constraints of layout items:

SizeConstraints_Menu

Selecting a specific command from the Size Constraints group does the following:

Command

Description

ResetToDefault Reset to default

Applies the default size constraints to the item, as described in the Default Size Constraints topic.

This command sets the layout item’s LayoutControlItem.SizeConstraintsType to Default.

FreeSizing Free sizing

Unlocks the upper limits of the item’s width and height that are specified by the MaxSize properties.

This command sets the layout item’s LayoutControlItem.SizeConstraintsType to Custom. The MaxSize.Width and MaxSize.Height properties are set to 0. The MinSize property is set to the default minimum (the same value as in the Default size constraints mode).

LockSize Lock Size

Locks the layout item’s current size, so the layout item can no longer be resized.

This command sets the LayoutControlItem.SizeConstraintsType to Custom. The MaxSize and MinSize properties are set to the value specified by the layout item’s BaseLayoutItem.Size property.

LockWidth Lock Width

Locks the layout item’s current width.

This command sets the LayoutControlItem.SizeConstraintsType to Custom. The MaxSize.Width and MinSize.Width properties are set to the value specified by the layout item’s Size.Width property. The MaxSize.Height and MinSize.Height properties remain unchanged.

LockHeight Lock Height

Locks the layout item’s current height.

This command sets the LayoutControlItem.SizeConstraintsType to Custom. The MaxSize.Height and MinSize.Height properties are set to the current height specified by the layout item’s Size.Height property. The MaxSize.Width and MinSize.Width properties remain unchanged.

See Also