Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Center Text align for labels

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?

like image 812
Sandy Avatar asked Sep 29 '11 18:09

Sandy


People also ask

How do I center align text in labels?

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.

How do I center align a label in HTML?

The <center> tag in HTML is used to set the alignment of text into the center.

What is an alignment of label?

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.


2 Answers

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).

like image 143
janbak Avatar answered Nov 08 '22 09:11

janbak


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.

like image 45
Ash Burlaczenko Avatar answered Nov 08 '22 09:11

Ash Burlaczenko