
DRelease方法是庆脊表单的常用方法,用于将表单从扰圆内存中释放,故而关闭当前表单的程序代码是This点Release。
其中的Release是表单对象的方法。
方法一:
关闭子窗体后
1、form2.Closed += (ss,ee)=> { this.Close() }
2、Application.OpenForms集合,找到要关闭的窗口,再Close:祥缺foreach (var item in Application.OpenForms),{ if (item is Form1) item.Close()}。
方法二:
B new_form = new B()
new_form.owner = this
this.hide()
new_form.showdialog()
Application.ExitThread()
Application.ExitThread()
首先默认情况下我们的程序是单线程的,罩没this.hide();把当前窗体隐藏起来了,然后new_form.showdialog();模态d出新窗口。这个时候线程不会继续执行,直到我们关闭了新d出来的模态窗口后,程序才会继续执行Application.ExitThread();此时线程关闭,所有一切都关闭了,隐藏的窗口也关谨闷辩闭了。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)