根据子标签的大小更改表单的大小
如何根据标签的宽度/长度更改表单大小?
我需要根据标签中有多少文本来调整表单的大小(文本是从 case 语句自动生成的)。
How would you change the Form size depending on the width/length of a Label?
I need to resize a Form depending on how much text there is in a Label (the text is automatically generated from case statements).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试将
Form
的AutoSize
设置为True打开

Form
并在其上放置Label
,标签有一个名称,比如Label1
。右键单击表单并打开“属性”

然后选择 AutoSize 为 True
然后返回到表单并双击表单,本例中为 Form1,Form1.vb 打开。
在
Form1_Load
中,如果它是另一个标签,则必须将其调整为正确的名称:运行它,它就在那里:
看这里 https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.form.autosize?view=windowsdesktop-6.0
You can try to put the
AutoSize
to True of theForm
Open the

Form
and put aLabel
on it , the Label gets a Name lets sayLabel1
.Rightclick on the Form and open Properties

Then Choose AutoSize to True
Then return to the Form and dubbleclick on the Form this case Form1, Form1.vb is open.
In
Form1_Load
if it is another Label you have to adjust it to the right Name:Run it and there it is :
Look here https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.form.autosize?view=windowsdesktop-6.0