父表单面板控件显示受限于该面板控件的多个子表单吗? [英] Parent form panel control showing multiple child forms constrained to the panel control?

查看:95
本文介绍了父表单面板控件显示受限于该面板控件的多个子表单吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写一个程序,该程序具有一个父窗口/窗体,该窗口/窗体的区域将是菜单项中的可选"子窗体.

我当前正在使用的路径试图在父窗口的面板控件中嵌套"一个子窗体.但是,我在尝试使子窗体在面板控件中进行初始化时遇到了麻烦.我不确定该怎么做.我现在可以有子窗体显示在选择菜单项时,但它不受限或固定的父窗口.

这是正确的方法吗?有更好的选择吗?

表格1:

I would like to code up a program that has a parent window/form that would have a region of it that will be a "selectable" child form from menu items.

The path I currently am on is trying to "nest" a child form in a panel control on the parent window. However, I''m having trouble trying to get the child form to initialize in the panel control. I''m not sure how to do this. I currently can have the child form display when the menu item is selected, but it is not constrained or fixed to the parent window.

Is this a correct approach? Is there a better alternative?

Form 1:

public partial class sfsResgenForm : Form
    {
        public sfsResgenForm()
        {
            InitializeComponent();


        }

        // Menu Item Controls

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)  // Exit Menu Item
        {
            if (MessageBox.Show("Close and Exit?", "Confirm Exit", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                // a 'DialogResult.Yes' value was returned from the MessageBox proceed with your action

                this.Dispose();
            }


        }

        private void newCharacterToolStripMenuItem_Click(object sender, EventArgs e)    // Go to Character Generator
        {
            chargenForm1 newMDIChild = new chargenForm1();
            // Set the Parent Form of the Child window.
            // newMDIChild.MdiParent = this;
            // Display the new form.
            newMDIChild.Show();




表格2:




Form 2:

public partial class chargenForm1 : Form
    {
        public chargenForm1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Dispose();

        }
    }



提前谢谢.

Sig Pimp



Thanks in advance.

Sig Pimp

推荐答案

尝试使用WPF-它对在窗口内嵌套窗口,在窗口内嵌套窗口等具有更好的支持...等等.

还有一些不错的库,例如 AvalonDock [ ^ ],它将帮助您管理UI. SAKryukov确实有一个要点-很多这​​样可能很容易使用户感到困惑...

最好的问候
Espen Harlinn
Try playing around with WPF - it has better support for nesting windows inside windows, nested inside windows - and so on ...

There are also nice libraries like AvalonDock[^] that will help you manage the UI. SAKryukov do have a point - to much of this may easily confuse users ...

Best regards
Espen Harlinn


听一个很好的友好建议:不要折磨自己和让用户感到厌恶-从不使用MDI .即使Microsoft也不鼓励使用它,并且几乎从未在任何实际工作的项目中使用过.

另请参见:
http://en.wikipedia.org/wiki/Multiple_document_interface#Disadvantages [在WPF中使用MDI窗口的问题 [ ^ ],
提供错误的MDIContainer [
Listen to a good friendly advice: don''t torture yourself and disgust your users — never use MDI. It is highly discouraged even by Microsoft and virtually never used in any really working projects.

See also:
http://en.wikipedia.org/wiki/Multiple_document_interface#Disadvantages[^],
Question on using MDI windows in WPF[^],
MDIContainer giving error[^].

Instead, do something simple and really robust and convenient. Simplest thing: make a tabbed UI in one form based on TabControl.

—SA


这篇关于父表单面板控件显示受限于该面板控件的多个子表单吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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