Working with Docking Property in C#.net-Trickcode

Working with Docking Property,Dock property , docking the control
Share it:

 Working with Docking Property 

The Dock Control allows you to dock the control to any of the edges of the form of its container. It's another way to make your controls intact when you resize the form. When you resize the form, the control remains docked to the edge specified. The Dock property accepts a value from the System.Windows.Forms.DockStyle enumeration. The following are the values available in this enumeration.

DockStyleDescription
BottomThe control's bottom edge is docked to the bottom edge of its containing control.
FillAll the edges of the control are docked to all the edges of its containing control and are sized appropriately.
LeftThe control's left edge is docked to the left edge of its containing control.
RightThe control's right edge is docked to the right edge of its containing control.
NoneThe control is not docked.
TopThe control's top edge is docked to the top edge of its containing control.
System.Windows.Forms.DockStyle Enumeration Values
Let's try docking a button control into different edges of the form.

Docking Property in C#.net
To dock a control, select the control to dock and go to Properties Window.
Docking Property


Find the Dock property and then click the drop-down button. You will be presented with a small window with multiple buttons specifying where to dock the control.
dock the control

The center square means that you will use the DockStyle.Fill value for the Dock property. The following screenshots show the effect of docking the control to different edges.
DockStyle
Bottom

Bottom dock style

Share it:

Windows Forms

Post A Comment:

0 comments: