Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Label position should fixed right and grow to left

How can I set my labels to align on the right even when they have diffrent lenghts. I have a set of labels which are occuring next to each other and also underneath each other.
The problem now is that they always align from the left within the label row,but I need them to align on the right as they are showing sums from other rows.

Just to verify I am not talking about the text align I am looking for a solution to align my labels.

Thanks in advance

like image 693
SwissGuy Avatar asked Feb 18 '11 16:02

SwissGuy


People also ask

How do you move a label to the center in HTML?

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


2 Answers

Simply set the AutoSize property to False in the designer. Adjust the size to fit the column. Then set the TextAlign to one of the right-alignment ones.

like image 134
Hans Passant Avatar answered Oct 25 '22 00:10

Hans Passant


You should be able to do it at runtime using the following code:

'find the current right alignment position
Dim rightAlign As Integer = Label1.Left + Label1.Width
'set the text (assumes AutoSize is set to True)
Label1.Text = value
'adjust position so the right hand point is in the same position as before
Label1.Left = rightAlign - Label1.Width
like image 22
Matt Wilko Avatar answered Oct 24 '22 23:10

Matt Wilko