Stop buttons stretching on resize when anchored left and right

I have a windows form with a whole bunch of buttons and labels all laid out nice and pretty like. I want them to stay more or less in the middle when the window is resized. Moving them horizontally is fine with bigger gaps between them. Or leave them exactly as I designed them in the center.

I have set the "Anchor" to "Bottom, Left, Right" and "Autosize" to "False". However, the labels don't move and the buttons stretch. Is there a way to stop this from happening?

I just got the labels to move by setting the "TextAlign" to "TopCenter". However, when resized enough the labels start disappearing by going under another label. So I guess the labels are stretching as well.
LVL 10
dij8Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Solar_FlareCommented:
I don't think you can do that with anchoring - you could try using a docked tableLayoutPanel - give it 3 columns and put your buttons in the center column and give all columns percentage widths rather than absolute widths.
0
Mike TomlinsonMiddle School Assistant TeacherCommented:
"Or leave them exactly as I designed them in the center."

If you want them to NOT resize and just stay centered then turn OFF all of the Anchor/Dock settings and they will stay just as you designed them in the middle of the form.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ChloesDadCommented:
It is streching because you have it anchored with respect to bottom left and bottom right.

If you want it to stay relative to one or the other then turn off either left or right, and it will stay relative to the one left on. By default controls are anchored to top left. You can't anchor a control to the centre of the form.

If yoou dont want users to resize the form then you can stop thyem from doing so using the properties of the form
0
Mike TomlinsonMiddle School Assistant TeacherCommented:
@ChloesDad:

    "You can't anchor a control to the centre of the form."

Sure ya can bud.  =)

See my comments above.  Turn OFF all of the Anchor properties and see what happens....
0
dij8Author Commented:
Here I was thinking I had to be clever to achieve this. No anchoring is indeed the answer. :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.