.NET 为什么“锚定"不考虑工具条? [英] .NET Why does "Anchor" not take Toolstrip into account?
本文介绍了.NET 为什么“锚定"不考虑工具条?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了一个表单并向其添加了一个 ToolStrip.
I have created a form and added a ToolStrip to it.
然后我添加了一个大按钮并将其固定在四面八方.
Then I added a big button and anchored it to all sides.
然后我创建了第二个按钮来设置 ToolStrip 可见和不可见:
Then I created a second button that would set the ToolStrip visible and invisible:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Me.ToolStrip1.Visible = Not Me.ToolStrip1.Visible
End Sub
但是,当我使 ToolStrip 不可见时,大按钮不会改变其大小和位置.
However, when I make the ToolStrip invisible, the big button does not change its size and position.
有人知道为什么吗?
谢谢!
推荐答案
通过使用 Panel
而不是 Form
来承载控件,您可以使事情按预期进行代码>.
You can make things work as you expect by using a Panel
to host the controls, rather than the Form
.
从空表格的角度来看:
- 添加
ToolStrip
- 添加一个
面板
- 将
Panel.DockStyle
设置为填充 - 将所有其余控件添加到面板
现在面板将根据 ToolStrip 的可见状态自动调整大小.
Now the panel will automatically resize based on the visible status of the ToolStrip.
这篇关于.NET 为什么“锚定"不考虑工具条?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文