Hi,
I have problem with VS 2010,
There is no way to dock to the centre...
The middle one is fill (covers the whole form)
Please Help!
:confused: :confused: :confused: :confused:
VS2010: How to dock to centre
Started by strider96, Nov 26 2009 11:49 AM
1 reply to this topic
#1
Posted 26 November 2009 - 11:49 AM
|
|
|
#2
Posted 14 December 2009 - 04:45 PM
you got that in other forum :D
If you want the control to stay in the middle of the form then it's not really docking. A ship doesn't dock in the middle of the ocean. Docking implies being adjacent to something. In the case of controls, they are docked to one or all sides of their container.
If you want a control to stay in the middle of a form and not get resized then you pretty much have two choices:
1. Add a TableLayoutPanel with three rows and three columns. Make the middle row and column auto-size so they will fit your control exactly, then make the other rows and columns 50% each. As the form resizes the TLP will expand and contract the outer rows and columns equally while keeping the middle row and column auto-sized to your control.
2. Handle the SizeChanged event of your form and manually calculate the new Location for the control. It's a pretty simple calculation based on the Height and Width of the form and the control.
If you want the control to stay in the middle of the form then it's not really docking. A ship doesn't dock in the middle of the ocean. Docking implies being adjacent to something. In the case of controls, they are docked to one or all sides of their container.
If you want a control to stay in the middle of a form and not get resized then you pretty much have two choices:
1. Add a TableLayoutPanel with three rows and three columns. Make the middle row and column auto-size so they will fit your control exactly, then make the other rows and columns 50% each. As the form resizes the TLP will expand and contract the outer rows and columns equally while keeping the middle row and column auto-sized to your control.
2. Handle the SizeChanged event of your form and manually calculate the new Location for the control. It's a pretty simple calculation based on the Height and Width of the form and the control.


Sign In
Create Account

Back to top









