如何自动调整文本大小以使其适合 vb.net 中的标签?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13872043/
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-17 11:33:10 来源:igfitidea点击:
How to automatically resize text to have it fit a label in vb.net?
提问by Anubhav Srivastava
I have a label that currently may contain words between 6 and x characters in length? However, when the word becomes too large, I want the text to change sizes so that it fits in the same amount of space. Is there any way to do this?
我有一个标签,目前可能包含长度在 6 到 x 个字符之间的单词?但是,当单词变得太大时,我希望文本改变大小以适应相同的空间量。有没有办法做到这一点?
回答by spajce
Private Sub Form1_SizeChanged(sender As Object, e As System.EventArgs) Handles Me.SizeChanged
Label1.Size = New Size(ClientSize.Width / 3, ClientSize.Height / 3)
Label1.Font = New Font("Arial", ClientSize.Height / 20)
End Sub

