单击控制框上的关闭按钮关闭第二个表单时,关闭第一个表单 [英] closing a first form when we closing a second form on clicking close button on control box

查看:97
本文介绍了单击控制框上的关闭按钮关闭第二个表单时,关闭第一个表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个解决方案,其中我有2个表单,其中当我单击表单右上角的关闭按钮时,然后在关闭form2表单1之前已关闭.......
给我一些代码........:(

A solution in which i has a 2 forms in which when i click close button on top right on a form then before closing a form2 form 1 was been closed .......
Give me some sort of code for it..... :(

推荐答案

我相信您想在用户单击关闭任何一个时关闭所有表单.您可以在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.


这篇关于单击控制框上的关闭按钮关闭第二个表单时,关闭第一个表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆