![]() |
Controls Properties: Anchoring a Control |
|
Introduction |
|
If you position a (visual) control on a form and if the control is positioned on the top left section of the form, when the user resizes the form, the control’s position would appear static, it would not move. This could be a concern if the control is positioned on the right, the bottom or the lower right sections of the form. When the user resizes the form, the control’s position would not be updated. Sometimes you will want the control to have the same location and/or distance with regard to the bottom, the right, and/or the lower right corners of the form. The ability to manage a control or a group of controls' location and size when the user resizes it is done using the Anchor property: |
![]() The Anchor property is created from the AnchorStyles enumeration. By default, when you add a control to a form, its position is relative to the top left corner of its container. You can also set the control’s position with regards to its container’s right and bottom borders. The Anchor property can be used to "glue" one border of a control to its parent using one of the following values: Bottom: The control bottom border will be the same even if the parent is heighten or shrunk
Left: The control left border will be the same even if the parent is widened or narrowed
None: No anchoring is applied
Right: The control right border will be the same even if the parent is widened or narrowed
In the same way, you can combine AnchorStyles values to "glue" one or more corners of a control to its parent when the parent is resized:
|
|
|
||
| Home | Copyright © 2008 FunctionX, Inc. | Home |
|
|
||