So here is my file label. If the label is too long, it will go off the screen thus making me have to scroll.
I've tried the following properties (separate times):
RightToLeft
as Yes ContentAlignment
as BottomRight or TopRight However, none of them are working. What is the correct property?
Try setting AutoSize
to false
(that makes a fixed size box). Then you can use the TextAlign
property to align the text - eg use MiddleRight
. That should do the trick.
Label label = new Label();
label.AutoSize = false;
label.TextAlign = ContentAlignment.MiddleRight;
In the properties window:
AutoSize = False
TextAlign = MiddleRight
In the designer:
只需删除 autosize = true
并设置RightToLeft = true
,标签现在将增长到左侧。
Yes AutoSize = false and RightToLeft = true will work. Note that when you set RightToLeft, the strange c# 2010 TextAlign TopLeft becomes aligned correctly to the right. If I set that to Top/Middle Right, the text jumps to the left instead!
Sample (WPF):
Label label = new Label();
label.HorizontalContentAlignment = HorizontalAlignment.Right;
This worked for me:
your_label_name.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
所有你需要做的标签才能使它工作:
Textalign = MiddleRight
Anchor = top and right
设置Autosize=true
和Textalign=MiddleRight
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.