Click here to Skip to main content
15,908,841 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
sir i have 3 label controls and it's contain text value is
label1.text="12345.00";
label2.text="1234.00";
label1.text="123.00";

when i debug my windows form then it looks like
12345.00
1234.00
123.00
but i don't want to show this type
i want to show

12345.00
1234.00
123.00
this looks...

but i don;t know how i done it..
Posted

select label & set property 'Autosize' = false,and give static width to label
then set it's property 'TextAlign' = MiddleRight
Happy Coding!
:)
 
Share this answer
 
v2
Comments
Shambhoo kumar 24-Aug-12 2:06am    
Thanks.....:)
Aarti Meswania 24-Aug-12 2:34am    
welcome :)
Try PadRight() method for strings. For example:
C#
label1.text="12345.00";

C#
label2.text="1234.00".PadRight(10);

C#
label3.text="123.00".PadRight(10);


Look at the following links for more information:
http://www.csharp-examples.net/align-string-with-spaces/[^]
http://www.dotnetperls.com/padright[^]
Also try following link in CP:
Label with Divider[^]
 
Share this answer
 
v2
Couple of points:
1. Change the AutoSize property. Default it is set to True. Change it to False.
2. Increase the size of the label to know, whether the TextAlign is working properly or not. For example, change Margin to (15, 0, 15, 0) and Size value to (175, 36)
3.
You need to set TextAlign property. TextAlign might contain any of the following values,
TopLeft    | TopCenter    | TopRight
MiddleLeft | MiddleCenter | MiddleRight
BottomLeft | BottomCenter | BottomRight

The default value is TopLeft. You can choose the value according to your need.
 
Share this answer
 
v3
hello,


i think you should insert your labels in tag ,see below,

C#
<span style="float:right"><asp:lable id="label2" xmlns:asp="#unknown"></asp:lable></span>


this will display right align,


hope this will help you
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900