且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

单击控制框上的关闭按钮关闭第二个表单时,关闭第一个表单

更新时间:2023-02-06 19:15:19

我相信您想在用户单击关闭任何一个时关闭所有表单.您可以在FormClosing事件处理程序中使用Application.Exit方法执行此操作.
Application.Exit不会引发FormClosingFormClosed事件.因此,如果这些处理程序中有任何代码,请确保首先调用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 using Application.Exit method in the FormClosing event handlers.

Application.Exit will not raise FormClosing or FormClosed event. So if you have any code in those handlers, make sure you call Form.Close first. While doing so, please be careful that you do not end up with never ending loops which will cause exceptions.