Setting the Anchor
property causes the control to attempt to keep a constant distance from the specified edges. So if you shrink the form, the label will still maintain its distance from Top
and Left
and should therefore not remain centered.
I actually think that if you want the label to stay centered, you should set its Anchor
property to None
, not to Top, Bottom, Left, Right
.
Now, if you are going to be changing the text of the label, here's a compromise:
- Set your label's
Anchor
property to None
. This will keep it centered.
- Set your label's
AutoSize
property to false
. This will allow you to specify a constant size.
- Set the size of the label to something substantially bigger than you'll need for whatever text you want to display. Center this resulting "bloated label" on your form.
- Set the
TextAlign
property of your label to MiddleCenter
.
In effect, what this gives you is a rectangle that is always centered in your form, inside of which is some text consistently centered within that rectangle.