Skip to main content

Layout Alignment Constraints

  • 2 minutes to read

Alignment of controls within the bounds of their layout items is managed automatically. ExpressLayout Control looks for items that have the same left/top/bottom/right boundaries and changes the offsets of the controls inside the items so that they (controls) are aligned in the same way as their items.

Automatic control alignment provides sufficient control in most instances. But in certain situations, additional assistance is required – something that will allow you to align items (not only controls), when auto alignment doesn’t work. Alignment constraints are designed for this very task.

These constraints can be applied using the “Align by…” button located in the Customization Form‘s Layout Tree View pane. This button is enabled if more than one item or group is selected.

In code, custom alignment is performed using TdxLayoutAlignmentConstraint objects. To create a TdxLayoutAlignmentConstraint object, call the layout control’s CreateAlignmentConstraint method.

An alignment constraint object is automatically destroyed, if the alignment it represents is no longer applied to two or more items.

The following image demonstrates how alignment constraints are applied to layout elements:

An element can be included in only one constraint (for each type). Constraints can be created, deleted or changed if an end-user wants to add/remove an element to/from a constraint. When an end-user selects an element that is affected by a constraint, all elements included in it are displayed differently.

See Also