在控制或形式,用户控件嵌入表单表单、控件、形式、用户

2023-09-03 03:46:58 作者:未完待续

好吧,我有一个大的CRUD应用程序,使用卡口与形式嵌入其中,像这样 - >

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);
    }

我然后调用下面父窗体的Form Load事件 - >

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);

这是给我的HERE在回答我的previous的问题。

This was given to me HERE in response to my previous question.

正如我已经取得进展,这一点,我不断收到nausiating感觉,嵌入式形式多层是一个等待发生的灾难和用户控件不断弹出。任何人都可以给我使用的用户控制VS嵌入形式的一些具体的建议吗?

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?

请参阅我的previous问题为灵感,以这一个。 HERE

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.

感谢您

推荐答案

我会用一个用户控件,它认为这只是简单的,你可以看到最新的设计师事情(如果你想),形式有一堆东西你我将永远不会需要,如果你的只是要使用它作为一个容器内的视图。

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.

与此相比,你的方法:

public static void DockControl(this Control control, UserControl userControl)
            {
                userControl.Dock = DockStyle.Fill;
                control.Controls.Clear();
                control.Controls.Add(userControl);
            }