Anchors Property

Applies to TestComplete 15.70, last modified on December 17, 2024

Specifies how the component is anchored to its parent.

Declaration

componentObj.Anchors
Read-Write Property String
componentObj     One of the user forms components listed in the Applies To section  

Applies To

The property applies to the following components:

TBevel, TcxButton, TcxButtonEdit, TcxCalcEdit, TcxCheckBox, TcxComboBox, TcxCurrencyEdit, TcxDateEdit, TcxGroupBox, TcxLabel, TcxListBox, TcxMemo, TcxMRUEdit, TcxProgressBar, TcxRadioGroup, TcxSpinEdit, TcxTextEdit, TcxTimeEdit, TImage, TPanel, TShape

Description

The Anchors property specifies how the component is anchored to its parent. Anchoring means that the component’s position relative to the specified parent’s size is fixed. So when the parent object is resized, the distance between the component and the specified size remains the same.

Property Value

A string containing the anchoring values separated by spaces or commas and optionally enclosed in square brackets. The property value is the combination of the following values:

Value Description
akLeft The component’s position is fixed relative to its parent’s left edge.
akTop The component’s position is fixed relative to its parent’s top edge.
akRight The component’s position is fixed relative to its parent’s right edge.
akBottom The component’s position is fixed relative to its parent’s bottom edge.

When setting the Anchors property from the User Forms editor, you should set the needed property flags of the Anchors property to True and other flags to False. For example, if you need to anchor the component to the left and top, you should set True to the akLeft and akTop flags and False to akRight and alBottom flags.

When you obtain the value of the Anchors property from scripts, the values are separated by commas. For example, if the component is anchored to the left and top, the Anchors property will return “akLeft,akTop”.

When you set the Anchors property value from scripts, you should separate values by commas or spaces and you can optionally enclose the string in square brackets. For example, all of the following variants are equivalent and valid:

UserForms.MyForm.MyComponent.Anchors = "akLeft,akTop";
UserForms.MyForm.MyComponent.Anchors = "akLeft akTop";
UserForms.MyForm.MyComponent.Anchors = "akLeft, akTop";
UserForms.MyForm.MyComponent.Anchors = "[akLeft,akTop]";
UserForms.MyForm.MyComponent.Anchors = "[akLeft akTop]";
UserForms.MyForm.MyComponent.Anchors = "[akLeft, akTop]";

Remarks

If you need to anchor the component to three edges, use the Align property.

See Also

Align Property

Highlight search results