在窗体的右上角带有X的按钮,如何捕获此事件@ C# [英] Button with an X at the upper-right corner of the form, how to catch this event @ C#

查看:99
本文介绍了在窗体的右上角带有X的按钮,如何捕获此事件@ C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用X按钮关闭表单时,会触发哪个事件? 我想要仅在按下X按钮时才触发的事件;我知道有一个FormClosing事件,但是问题是每次关闭表单时都会触发... 当frm.close()执行时,它也会触发,我不希望发生这种情况.

Which event is fired when I close a form with the X button? I want the event that fires only when the X button is pressed; I know that there is a FormClosing event, but the problem is that it fires each time when form is closed... It also fires when frm.close() executes, and I don't want that to happen.

推荐答案

在表单的右上角没有特定的事件与X关联.

There is no specific event wired up to the X in the upper right hand corner of the form.

相反,请使用表单的

Instead, use the form's FormClosing event. It has a Cancel parameter which you can set to true if you don't want the form to close. This allows you to check for form closings that take place via other means, such as the OK button being clicked.

这篇关于在窗体的右上角带有X的按钮,如何捕获此事件@ C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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