Vb.net - 在我的标签内居中文本!

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3527360/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 15:00:43  来源:igfitidea点击:

Vb.net - Centering Text inside my label!

vb.netlabelframe

提问by Beho86

I am trying to make my first program in vb.net 2010, and I have a question.

我正在尝试在 vb.net 2010 中制作我的第一个程序,我有一个问题。

You know how when you have a button, the text centers itself within the frame of the button? I have a label in my application, that displays a different text (through the label) everyday.

你知道当你有一个按钮时,文本如何在按钮的框架内居中?我的应用程序中有一个标签,每天显示不同的文本(通过标签)。

How can I limit the text area, like the frame in the button, and center the text in this text area? Or if it's easier to use the button, how can I remove the frame?

如何限制文本区域,例如按钮中的框架,并将文本居中放置在该文本区域中?或者如果使用按钮更容易,我该如何移除框架?

回答by Nate

Change the property AutoSizeto false and set the TextAlignproperty to the center.

将该属性更改AutoSize为 false 并将该TextAlign属性设置为中心。