I have a label exactly in center of a form with text "It is my Visual Studio application". Now, I have a button click event that changes the text to "My application". But the problem is the alignment gets disturbed as the length of changed text is different from previous one. I tried TextAlign option of label to MiddleCenter. but no luck. Can any one help?
Click on the Layout tab and find the nine alignment icons in the “Alignment” section. Click on the middle “Centre” icon to apply a central alignment to the entire table – and your label template. Any items you now add will be centrally aligned by default.
The <center> tag in HTML is used to set the alignment of text into the center.
Definition of ALIGNMENT:The template itself must then also align with the labels being printed, so that each copy of the design is printed in the correct position on each of the labels.
You can even do better: set the label Autosize OFF, and manually stretch the label in the designer to fill the area that's needed to show the largest text value. Now if you set the TextAlign to MiddleCenter, you get the effect you want (even in the designer, so you can check it by setting a value in the Text property).
You will also need to set the width of the label to the length of your longest text, or just to the width of the form.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With