更新时间:2023-12-06 09:00:28
考虑使用 UserControl
代替.它的设计方式与 Form
相同,但它没有边框,旨在用于其他表单中.
Consider using a UserControl
instead. It is designed the same way as a Form
but it does not have borders and it is intended to be used inside other forms.
您只需编译包含它的项目一次,以便它出现在 Visual Studio 工具箱中(假设该项目在同一个解决方案中,并且与包含 Form
的项目是同一项目)或引用它.
You only have to compile the project that contains it once so that it appears in Visual Studio toolbox (assuming the project is in the same solution and is either the same project as the one containing the Form
or has a reference to it.
或者,您可以像在示例中所做的那样动态加载它.但是如果你系统地加载同一个单用户控件,在设计器中更容易做到...
Or alternatively, you can load it dynamically similar to what you have done in your example. But if you systematically load the same single user control, it is easier to do in the designer...
有时,您可能还想对布局进行一些调整.
Sometime, you might also want to make some adjustment to the layout.