xtd 0.2.0
Loading...
Searching...
No Matches

◆ anchor() [2/2]

virtual control & xtd::forms::control::anchor ( xtd::forms::anchor_styles  anchor)
virtual

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

Parameters
anchorA bitwise combination of the xtd::forms::anchor_styles values. The default is xtd::forms::anchor_styles::top and xtd::forms::anchor_styles::left.
Returns
Current control.
Remarks
Use the xtd::forms::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 form with a button whose xtd::forms::control::anchor property value is set to xtd::forms::anchor_styles::top and xtd::forms::anchor_styles::bottom, the button is stretched to maintain the anchored distance to the top and bottom edges of the form as the height of the form is increased.
Note
The xtd::forms::control::anchor and xtd::forms::control::dock properties are mutually exclusive. Only one can be set at a time, and the last one set takes precedence.
Warning
Set the xtd::forms::control::anchor property after setting the xtd::forms::control::location and xtd::forms::control::size.
Notes to Inheritors
When overriding the anchor property in a derived class, use the base class's anchor property to extend the base implementation. Otherwise, you must provide all the implementation. You are not required to override both the get and set accessors of the anchor property; you can override only one if needed.