本文介绍了C#Windows窗体:在关闭待办事项【工艺】的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能得到,当它被关闭我的窗口形式做一些事情。

How can I get my windows form to do something when it is closed.

推荐答案

处理的 FormClosed 事件。

要做到这一点,转到事件选项卡在属性窗口,然后双击 FormClosed 事件添加一个处理程序。

To do that, go to the Events tab in the Properties window and double-click the FormClosed event to add a handler for it.

您就可以把你的代码生成的 MyForm_FormClosed 处理程序。

You can then put your code in the generated MyForm_FormClosed handler.

您也可以让这个通过覆盖 OnFormClosed 方法;要做到这一点,键入覆盖onformcl 在代码窗口和 OnFormClosed 从智能感知。

You can also so this by overriding the OnFormClosed method; to do that, type override onformcl in the code window and OnFormClosed from IntelliSense.

如果您希望能够防止封闭形式,办理的FormClosing 事件,而是和设置 e.Cancel 真正

If you want to be able to prevent the form from closing, handle the FormClosing event instead, and set e.Cancel to true.

这篇关于C#Windows窗体:在关闭待办事项【工艺】的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 11:37