关闭所有表格-主表格和子表格 [英] close all forms-main and sub
本文介绍了关闭所有表格-主表格和子表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
然后程序将关闭主窗体和所有其他子窗体....
请..帮助..
谢谢...
解决方案
容易-在构造子窗体FormClosed事件时(在使用Show函数之前)将处理程序添加到子窗体FormClosed事件中. 在处理程序中,关闭当前表单.
[edit]忘记了FormClosed ...的Form部分...-OriginalGriff [/edit]
您需要覆盖方法System.Windows.Forms.OnFormClosing
.您可以取消关闭表单,而将事件参数参数的属性Cancel
分配给true
.您可以通过处理事件System.Windows.Forms.FormClosing
获得相同的效果.您还可以检查在相同参数中传递的关闭原因并采取相应措施.
事件System.Windows.Forms.FormClosed
也会检测到"它,但是现在更改或取消为时已晚,无论如何该表单都将关闭.
—SA
我会使用my.application.openforms
在窗体上的关闭事件调用使用my.application.openforms
的常规
Openforms [ 解决方案
Easy - add a handler to the sub form FormClosed event when you construct it (and before you use the Show function).
In the handler, close the current form.
[edit]Forgot the Form part of FormClosed... - OriginalGriff[/edit]
You need to override the methodSystem.Windows.Forms.OnFormClosing
. You may cancel closing the form my assigningtrue
the the propertyCancel
of event arguments parameter. You can get the same effect by handling the eventSystem.Windows.Forms.FormClosing
. You can also check the closing reason passed in the same argument and act accordingly.
The eventSystem.Windows.Forms.FormClosed
will "detect" it, too, but this is too late to change or cancel — the form will be closed anyway.
—SA
I would use themy.application.openforms
on the form close events call a rountine that uses themy.application.openforms
Openforms[^]
you will need to enumerate that form collection but remember to the active form last.
this way you can also perform any save / delete functions that you want before the form is closed.
这篇关于关闭所有表格-主表格和子表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文