问题描述
Okay I have a large CRUD app that uses tabs with Forms embedded in them like so -->
public static void ShowFormInContainerControl(Control ctl, Form frm)
{
frm.TopLevel = false;
frm.FormBorderStyle = FormBorderStyle.None;
frm.Dock = DockStyle.Fill;
frm.Visible = true;
ctl.Controls.Add(frm);
}
I then call the below in the Form Load event of the Parent Form -->
// Embedd the child form in the this Parent
WinFormCustomHandling.ShowFormInContainerControl(pnlModuleHost, _frmWWCModuleHost);
This was given to me HERE in response to my previous question.
As I have progressed in this I keep getting the nausiating feeling that multiple layers of embedded Forms are a disaster waiting to happen and User Controls keep popping up. Can anyone offer me some concrete advice on using user controls vs embedding forms?
See my previous question for the inspiration to this one. HERE
Also a screen shot of what my current embedded form layout looks like in action can be found HERE.
Thank You
I would use a UserControl, its think there just simpler, you can see whats going on in the designer (if you want), Form has bunch of stuff you'll never need if your just going to use it as a view within a container.
Compare this to your method:
public static void DockControl(this Control control, UserControl userControl)
{
userControl.Dock = DockStyle.Fill;
control.Controls.Clear();
control.Controls.Add(userControl);
}
这篇关于控件中的嵌入式表单或作为用户控件的表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!