在控制或形式,用户控件嵌入表单 [英] Embedded Form in a control or Form as User Control

查看:109
本文介绍了在控制或形式,用户控件嵌入表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我有一个大的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);

这是给我的<一个href="http://stackoverflow.com/questions/543087/custom-class-for-dealing-with-embedding-in-forms/545864#545864">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问题为灵感,以这一个。 <一href="http://stackoverflow.com/questions/820461/ui-design-of-winform-crud-app-what-works">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);
            }

这篇关于在控制或形式,用户控件嵌入表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆