System.Windows.Forms.Control.Anchor Property

Gets or sets the edges of the container to which a control is bound and determines how a control is resized with its parent.


[System.ComponentModel.DefaultValue(System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)]
public virtual AnchorStyles Anchor { set; get; }


Documentation for this section has not yet been entered.


Use the Control.Anchor property to define how a control is automatically resized as its parent control is resized. Anchoring a control to its parent control ensures that the anchored edges remain in the same position relative to the edges of the parent control when the parent control is resized.

You can anchor a control to one or more edges of its container. For example, if you have a System.Windows.Forms.Form with a System.Windows.Forms.Button whose Control.Anchor property value is set to Top and Bottom, the System.Windows.Forms.Button is stretched to maintain the anchored distance to the top and bottom edges of the System.Windows.Forms.Form as the Control.Height of the System.Windows.Forms.Form is increased.


The Control.Anchor and Control.Dock properties are mutually exclusive. Only one can be set at a time, and the last one set takes precedence.


Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Assembly Versions: 1.0.5000.0,