执行code,当我的窗体关闭 [英] Executing code when my form is closed

查看:101
本文介绍了执行code,当我的窗体关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的程序使得在注册表中的一些变化,而它的运行,如果他们没有正确回滚,他们可能会造成用户的一些问题。例如,他们可能不能够使用他们的互联网连接。

My program makes some changes in the registry while it's running, and if they are not properly rolled back, they might cause the user some problems. FOr example, they might not be able to use their Internet connection.

所以,我需要确保当他们关闭应用程序,我回到一切恢复正常。要做到这一点,我需要知道,当他们有pressed形式的关闭按钮。我该怎么办呢?有没有办法,我可以处理一个事件?

So I need to make sure that when they close the application, I return everything back to normal. To do this, I need to know when they have pressed the Close button of the form. How can I do that? Is there an event that I can handle?

推荐答案

我认为你需要的是不能访问的关闭按钮,而是进入的事件的被解雇的形式时,是封闭的。

I think that what you need is not access to the close button, but rather access to the event which is fired when the form is closed.

这 previous SO后,你可能需要的是一样的东西因此:

Taken from this previous SO post, what you might need is something like so:

void FormClosed(object sender, FormClosedEventArgs e)
{
    // do something useful
}

这篇关于执行code,当我的窗体关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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