asp教程.net c# winfrom窗体自动打开与关闭
if (this.checkchildfrmexist("addfrom") == true)
{
return;
}
addfrom form2 = new addfrom();
form2.mdiparent = this;
form2.show();private bool checkchildfrmexist(string childfrmname)
{
foreach(form childfrm in this.mdichildren)
{
if(childfrm.name == childfrmname)
{
if(childfrm.windowstate == formwindowstate.minimized)
childfrm.windowstate = formwindowstate.normal;
childfrm.activate();
return true;
}
}
return false;
}
//"关闭的时候用addfrom.close()关闭"
//方法二
if (from1 == null || from1.isdisposed)
{
from1 = new from1();
}
else
{
from1.activate();
}