检查用户是否单击关闭按钮 [英] Checking if user click the close button

查看:78
本文介绍了检查用户是否单击关闭按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I am using vb.net form. I was wondering if there is an event (or way ) that check if when the user click the close form button?

If yes, can you also cancel the form from closing ?

推荐答案

是的,有一种方法,奇怪的是,它被称为FormClosing事件,你只需要拦截它。



FormClosing事件 [ ^ < MSDN上的/ a>]对如何使用它有很好的参考。
Yes, there is a way, oddly enough, its called the FormClosing event, and you just need to intercept it.

FormClosing Event[^] on MSDN has a good reference for how to use it.


是的,是的。

处理Form.FormClosing事件,它将会给你一个FormClosingEventArgs作为参数。

这包含一个属性
CloseReason [ ^ ]它会为您提供尽可能多的信息,并且还有取消 [ ^ ]您可以设置为 True <的属性/ code>如果你想阻止它关闭。

注意:如果你总是取消表格关闭,你会严重惹恼你的用户!为他们提供一些机制......
Yes, and yes.
Handle the Form.FormClosing event, and it will give you a FormClosingEventArgs as a parameter.
This contains a property CloseReason[^] which gives you as much info as you are going to get, and also has a Cancel[^] property that you can set to True if you want to prevent it closing.
Note: if you always cancel the Form Close, you will seriously annoy your users! Provide some mechanism for them to get out...


这篇关于检查用户是否单击关闭按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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