从另一个孩子关闭儿童形式 [英] close child form from another child

查看:85
本文介绍了从另一个孩子关闭儿童形式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,先生,



今天,我创建了一个MDI父母和许多子形式。我希望在一个子表单运行时关闭所有子表单。当任何一个子表单打开时,所有子表单都会自动关闭。不应关闭运行表单。只有活动才能关闭另一个表格..



给我这个代码的代码。



解决这个问题...



感谢你.......

解决方案

传递活动表格对象对于以下方法,它将关闭除活动表单之外的所有其他表单。

  public   void  DisposeAllButThis(表单表单)
{
foreach (表单frm in this .MdiChildren)
{
if (frm.GetType()== form.GetType()
&& frm!= form)
{
frm.Close();
}
}
}





希望这有帮助


< blockquote>请参阅此链接,您可以得到答案:



http://www.daniweb.com/software-development/csharp/threads/225882/how-to- close-all-child-forms-in-mdi-form-c.net [ ^ ]



http://stackoverflow.com/questions/7142230/close-mdi -child-form-from-another-form [ ^ ]



如果有帮助,接受答案并投票。


  public   void  CloseAllForms(表格形式)
{
foreach (表格frm .MdiChildren)
{
if (frm.GetType()== form.GetType()&& frm!= form)
{
frm.Close();
}
}
}


Hello sir,

Today, i have create one MDI parent and many child form. I want to close all child form when one child form is running.another all child form is automatically close when any one child form open. Running form should not be closed. only closed another forms if active..

Give me code for this mater.

solve this problems...

Thanking you.......

解决方案

Pass the active form object to the below method it will close all the other form except the active form.

public void DisposeAllButThis(Form form)
{
    foreach (Form frm in this.MdiChildren)
    {
        if (frm.GetType() == form.GetType()
            && frm != form)
        {
            frm.Close();
        }
    }
}



Hope this helps


Refer this link here you can get you answer :

http://www.daniweb.com/software-development/csharp/threads/225882/how-to-close-all-child-forms-in-mdi-form-c.net[^]

http://stackoverflow.com/questions/7142230/close-mdi-child-form-from-another-form[^]

Accept as answer and vote if help.


public void CloseAllForms(Form form)
{
    foreach (Form frm in this.MdiChildren)
    {
        if (frm.GetType() == form.GetType() && frm != form)
        {
            frm.Close();
        }
    }
}


这篇关于从另一个孩子关闭儿童形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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