简体   繁体   English

如何以父表单关闭以前的mdi子项

[英]How to close previous mdi child in parent form

I have a mdi parent form and I open my other forms in run time as mdi child form by this code: 我有一个mdi父form ,我通过以下代码在运行时打开我的其他forms作为mdi子表单:

private void MenuItem_Click(object sender, EventArgs e)
{
    childform = new childform ();
    frm.MdiParent = Mdiparent;
    frm.WindowState = FormWindowState.Maximized;
    frm.Show();
}

but the problem is: When current form is open, user can open another form and it can be repeated several times so that each form is opened what's code for closing the current child form before user open a new child form?? 但问题是:当当前表单打开时,用户可以打开另一个表单,并且可以重复多次,以便打开每个表单,以便用户打开新的子表单之前关闭当前子表单的代码?

tanx for ur assist :) I Found effective code by test other Members in Class Windows.forms just enough check this : tanx for ur assist :)我发现有效的代码通过测试类Windows.forms中的其他成员来检查这个:

if (ActiveMdiChild != null)
    ActiveMdiChild.Close();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM