Specifies whether an object stays in the same relative position when its container is resized.

Property of

ActiveX, Browse, Container, Editor, Image, Grid, NoteBook, OLE, ReportViewer, TabBox, Text, TreeView

Description

Use anchor to specify whether a control should maintain its location and resize itself to match its container, which is usually the form. Anchored controls claim space in the order in which they are created (the z-order). Once an anchored control claims space in its container, that space cannot be used by another anchored control.

anchor is an enumerated property and, with the exception of TabBox controls, accepts the following values:

Value

Description

0

None, do not anchor

1

Bottom

2

Top

3

Left

4

Right

5

Center

6

Container

When anchored to the bottom or top, the width of the control resizes to match the width of its container. When anchored to the left or right, the height of the control resizes to match the height of its container. Center and container anchors behave identically: the control fills the center of the container, sizing itself to fill all the space not claimed by another anchored control; if there are no other anchored controls in the container, the control resizes to fill its container.

When used with TabBox controls, the anchor property accepts only these values,

0 - Do not anchor

1 - Bottom