MDIChild表单仅打开 [英] MDIChild form open only

查看:158
本文介绍了MDIChild表单仅打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了具有MDIParent形式和其他形式的应用程序.
Mdiparent允许打开多个表单.不应这样做,应该这样做.
我在下面有表格的示例代码.

I have created application that have MDIParent form and other no of forms.
Mdiparent allowing to open multiple forms. That should not be allowed so should do.
I have sample code for form below.

private void employeeEntryToolStripMenuItem_Click(object sender, EventArgs e)
       {
           frmEmployeeEntry EmpEntry = new frmEmployeeEntry();
           EmpEntry.MdiParent = this;
           EmpEntry.Show();
       }








里面有什么问题.
建议正确的代码.








What''s wrong in it.
Suggest right code pls.
Thanks in advamce.

推荐答案

嗨...

在打开子窗体之前,您应检查是否已打开任何mdichildren窗体,如果是,则将其关闭,如下所示:
hi...

before opening a child form, u should check whether any mdichildren forms are open, and if yes, close them, like below:
foreach(Form frmChild in this.MdiChildren)
{
frmChild.Close();
}



之后,您可以打开新表单.



After this, u can open new form.


在这种情况下输入新的子表单打开代码
put new child form opening code inside this condition
if (MDI.MdiChildren.Length >0)
{
 //message please close form already open
}
else
{
 //open form
}



其他简单的方法,
使用 ShowDialog 注意:在关闭此表单之前,将不允许访问MDI表单.



else simple way,
use ShowDialog note: it will not allow to access MDI form till this form is closed.

frmEmployeeEntry EmpEntry = new frmEmployeeEntry();
EmpEntry.ShowDialog()


祝您编码愉快!
:)


Happy Coding!
:)


这篇关于MDIChild表单仅打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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