如何以正确的对齐方式设置标签值 [英] How to set lable value in right alignment

查看:98
本文介绍了如何以正确的对齐方式设置标签值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生,我有3个标签控件,并且包含文本值,是
label1.text ="12345.00";
label2.text ="1234.00";
label1.text ="123.00";

当我调试Windows窗体时,它看起来像
12345.00
1234.00
123.00
但我不想显示这种类型
我想展示

12345.00
1234.00
123.00
这看起来...

但是我不知道我是怎么做到的..

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

推荐答案

选择标签&设置属性`` Autosize ''= false ,并为标签赋予静态宽度
然后设置其属性'' TextAlign ''= MiddleRight
祝您编码愉快!
:)
select label & set property ''Autosize'' = false,and give static width to label
then set it''s property ''TextAlign'' = MiddleRight
Happy Coding!
:)


尝试使用PadRight()方法处理字符串.例如:
Try PadRight() method for strings. For example:
label1.text="12345.00";


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


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



请查看以下链接以获取更多信息:
http://www.csharp-examples.net/align-string-with-spaces/ [< ^ ]
http://www.dotnetperls.com/padright [带有分隔符的标签 [



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[^]


点对:
1.更改AutoSize 属性.默认情况下,它设置为True.将其更改为False.
2.增加标签的大小,以了解TextAlign是否正常工作.例如,将Margin 更改为(15,0,15,0),将Size 值更改为(175,36)
3.
您需要设置TextAlign属性. TextAlign可能包含以下任何值,
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


默认值为TopLeft.您可以根据需要选择值.


The default value is TopLeft. You can choose the value according to your need.


这篇关于如何以正确的对齐方式设置标签值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆