[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] | Reference for unit 'Controls' (#lcl)

# TAnchorSide

[Properties (by Name)] [Methods (by Name)] [Events (by Name)]

Specifies how the side of a control is anchored to other controls.

## Declaration

Source position: controls.pp line 931

`type TAnchorSide = class(TPersistent)`
`protected`
`function GetOwner; override;` |  | Gets the owner of the persistent object.
`public`
`constructor Create();` |  | Constructor for the class instance.
`destructor Destroy; override;` |  | Destructor for the class instance.
`procedure GetSidePosition();` |  | Get information about the target control, side and side position.
`function CheckSidePosition();` |  | Checks for anchor cycles and invalid targets, and returns information about the target side.
`procedure Assign(); override;` |  | Copies properties from the specified persistent object into the current class instance.
`function IsAnchoredToParent();` |  | True when we are anchored to our parent, at least on the ParentSide.
`procedure FixCenterAnchoring;` |  | Remove conflicting anchors.
`property Owner: TControl; [r]` |  | The control being anchored.
`property Kind: TAnchorKind; [r]` |  | The control side being anchored.
`published`
`property Control: TControl; [rw]` |  | The target control of the anchor.
`property Side: TAnchorSideReference; [rw]` |  | The side of the target Control, to which we anchor.
`end;`

## Inheritance

`TAnchorSide` |  | Specifies how the side of a control is anchored to other controls.
`TPersistent`
?
`TObject`

## Description

Class holding the reference sides of the anchors of a TControl. Every TControl has four AnchorSides: AnchorSide[akLeft], AnchorSide[akRight], AnchorSide[akTop] and AnchorSide[akBottom]. Normally if Anchors contain akLeft, and the Parent is resized, the LCL tries to keep the distance between the left side of the control and the right side of its parent client area. With AnchorSide[akLeft] you can define a different reference side. The kept distance is defined by the BorderSpacing. For example:

    +-----+  +-----+
    |  B  |  |  C  |
    |     |  +-----+
    +-----+

If you want to have the top of B the same as the top of C use

    B.AnchorSide[akTop].Side:=asrTop;
      B.AnchorSide[akTop].Control:=C;

If you want to keep a distance of 10 pixels between B and C use

    B.BorderSpacing.Right:=10;
      B.AnchorSide[akRight].Side:=asrLeft;
      B.AnchorSide[akRight].Control:=C;

Do not setup in both directions, because this will create a circle, and circles are not allowed.

Another example:

    +-------+
    |       | +---+
    |   B   | | A |
    |       | +---+
    +-------+

Centering A relative to B:

    A.AnchorSide[akTop].Side:=asrCenter;
      A.AnchorSide[akTop].Control:=B;

Or use this equivalent:

    A.AnchorSide[akBottom].Side:=asrCenter;
      A.AnchorSide[akBottom].Control:=B;