简体   繁体   English

如果标签宽度不适合C#Windows窗体应用程序中的文本宽度,如何使标签中的文本像(选取框)一样移动?

[英]How can i make the text in the label move like in (marquee) if the label width not fit the text width in C# windows form application?

Is there a way to make the label text move as in marquee but in windows form application , thanks. 有没有一种方法可以使标签文本像字幕一样移动,但是在Windows窗体应用程序中,谢谢。 Thanks. 谢谢。

It isn't exactly clear where you might want to move the text to, if it doesn't fit the layout then there are no real options. 目前尚不清楚您可能要将文本移到哪里,如果它不适合布局,则没有实际的选择。 In general, window layouts are contrained width-wise but have some room for growth vertically. 通常,窗口布局在宽度方向上受限制,但在垂直方向上仍有一定的增长空间。 Enforce this by setting the Label's MaximumSize property to, say, (100,0) so it cannot grow in the width and overlap some other control. 通过将Label的MaximumSize属性设置为(100,0)来强制执行此操作,以使其不能在宽度上增长并与其他控件重叠。 That will make it start wrapping text and use more vertical space. 这将使它开始包装文本并使用更多的垂直空间。

If that's a problem as well then set AutoSize = False and AutoEllipsis = True. 如果这也是一个问题,则设置AutoSize = False和AutoEllipsis = True。 The user can now tell that the text got truncated. 用户现在可以告诉文本被截断了。 And automatically gets a tooltip when she hovers the label. 当她悬停标签时自动获得工具提示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM