AdBlock Detected

We provide high-quality source code for free. Please consider disabling your AdBlocker to support our work.

Buy me a Coffee

Saved Tutorials

No saved posts yet.

Press Enter to see all results

Working with Docking Property in C#.net-Trickcode

By pushpam abhishek
Listen to this article

 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 this post

pushpam abhishek

About pushpam abhishek

Pushpam Abhishek is a Software & web developer and designer who specializes in back-end as well as front-end development. If you'd like to connect with him, follow him on Twitter as @pushpambhshk

Comments