在容器中动态显示表单的最佳方法是什么?

问题描述:

我有一个主要表单,我想用它作为标题部分,菜单部分的容器,然后该区域的其余部分将用于显示基于菜单选择或先前表单选择的表单。本节中一次只显示一个表单。



我创建了无边界表单,但需要知道如何将菜单按钮点击链接到显示表单显示区域中的表单。我应该使用面板吗?什么是在VB 2010中使用的按钮单击代码?





< img src =http://i36.photobucket.com/albums/e23/jharding08/Layout_zpsb0900284.pngborder =0 alt =photo Layout_zpsb0900284.png/>

I have a main form which I would like to use as a container for a header section, menu section and then the rest of the area will be used to display a form based on either the menu selection or a previous form selection. There will be only one form displayed at a time in this section.

I have the borderless forms created, but need to know how to link the menu button clicks to displaying the forms in the "Form Display" area. Should I use a panel? And what is the button click code to usein VB 2010?


<img src="http://i36.photobucket.com/albums/e23/jharding08/Layout_zpsb0900284.png" border="0" alt=" photo Layout_zpsb0900284.png"/>

不太确定按钮点击代码是什么。但是,我会使用用户控制,因为我不相信您可以在表格中填写表格。以下是按钮点击的代码可能如下所示:



Not too sure what the button click code would be. However I would go with a User Control because I don't believe you can have a Form within a Form. Here is what the code for the button clicks would probably look like:

function button1_click
    DispalyPanel.Controls.Remove(Control2)
    Control2.Dispose()
    DispalyPanel.Controls.Add(Control1)
end function





您可能需要设置在每次单击事件中显示设置(例如填充和停靠)以使控件填充面板。



You may have to set the display settings (such as fill and dock) in each click event to make the control fill the panel.


您需要使用一组具有属性的某些值的面板 Control.Dock 。从这里开始显示每个案例的值(避免使用默认的):

http://msdn.microsoft.com/en-us/library/system.windows.forms。 dockstyle(v = vs.110).aspx [ ^ ],

http://msdn.microsoft.com/en-us/library/system.windows.forms.control.dock%28v= vs.110%29.aspx [ ^ ]。



此外,你应该更好地使用一些内部面板,说,你的按钮和其他东西。您需要将 Dock Control.Padding 属性结合使用:

http://msdn.microsoft.com/en-us/ library / system.windows.forms.control.padding(v = vs.110).aspx [ ^ ]。



-SA
You need to use a set of panels with certain values of the property Control.Dock. The value for each case should be apparent from here (avoid using the default None):
http://msdn.microsoft.com/en-us/library/system.windows.forms.dockstyle(v=vs.110).aspx[^],
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.dock%28v=vs.110%29.aspx[^].

Moreover, you should better use a number of inner panels, say, for your buttons and other things. You need to combine Dock with Control.Padding property:
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.padding(v=vs.110).aspx[^].

—SA


看起来就是这样。感谢您的帮助
Looks like that is the way to go. Thank you for your help