更新时间:2023-02-06 19:15:19
我相信您想在用户单击关闭任何一个时关闭所有表单.您可以在FormClosing
事件处理程序中使用Application.Exit
方法执行此操作.Application.Exit
不会引发FormClosing
或FormClosed
事件.因此,如果这些处理程序中有任何代码,请确保首先调用Form.Close
.这样做时,请注意不要以永无休止的循环结束,循环会导致异常.
I believe you want to close all the forms when the user clicks close on any of the forms. You can do this usingApplication.Exit
method in theFormClosing
event handlers.Application.Exit
will not raiseFormClosing
orFormClosed
event. So if you have any code in those handlers, make sure you callForm.Close
first. While doing so, please be careful that you do not end up with never ending loops which will cause exceptions.