Anchoring and Docking in Visual Basic .NET

In this article, I will explain you about Anchoring and Docking in Visual Basic .NET.
  • 7384

In this article, I will explain you about Anchoring and Docking in Visual Basic .NET.

Anchoring

In visual Basic .NET when we want to resize the controls dynamically with the form then we useAnchoring. Suppose, we are designing a form and that form can be resized by the user at run time then for proper resize and reposition of the controls on your form is must. Anchor position for the control is defined in Anchor properties. When we set the anchor properties of the control of a form and the form is resized, the distance between the control and the anchor position is maintained.

Anchoring a control

By default controls are anchored to the top and left side. If you want to anchor a control, click on the control which you want to anchor. Open the Properties Window and select Anchor property and set an anchor, click the top, leftright, or bottom section of the cross. Click that side of the cross which you want to clear a side of the control which has been anchored. When you run the form the distance from the anchored position were always remains the same as the distance defined for the control during design time. The image below will show you that.

img1.gif
 


 

img2.gif
 

Docking

In Visual Basic .NET when we want a control, address to the edges of its container form then we use Docking. Suppose, we are designing a form and we want that the particular control address to the particular edge of its container form then we have to dock a control. It can be done by selecting the Dock property of that control from the properties window. When you select the dock property, you see the small editor from which you can select the side on the form in which the control should be docked.

Docking a control

By default the dock property of the controls is selected to None. If you want to dock a control, click on the control which you want to dock. Open Properties Window and select the Dockproperty. In the small editor click the button that represents the edge of the form where you want to dock the control. The image below will show you that.

img3.gif
 


 

img4.gif
 

Summary

I hope this article help you to understand about Anchoring and Docking in Visual Basic .NET.

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.