VB.NET当用户单击X(关闭程序)超载默认功能 [英] VB.NET overload default functionality when user clicks the X (Close Program)

查看:257
本文介绍了VB.NET当用户单击X(关闭程序)超载默认功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何去覆盖默认的功能,当用户单击一个VB.NET基于表单的应用程序在X?

How do I go about overriding the default functionality when a user clicks the X in a VB.NET form-based application?

我目前正在处理MyBase.Closing事件......但因为它是一个DirectX的应用程序,我需要让形式在收盘前做一些清理工作。

I am currently handling the MyBase.Closing event... but since it's a DirectX app, I need to do some cleanup before allowing the form the close.

推荐答案

如果你想要做一些额外的清理窗体关闭之前,这样做在窗体的的表Closing事件

If you want to do some extra clean up before a form closes, do so in the form's Form Closing event.

这个事件,您还可以通过接近该事件的的 FormClosingEventArgs.Cancel财产。本次活动的<一个href="http://msdn.microsoft.com/en-us/library/system.windows.forms.formclosingeventargs.closereason.aspx"相对=nofollow> CloseReason 属性将告诉您为什么该事件被称为(您想检查的 CloseReason.UserClosing

This event also allows you to cancel the form close through the event's FormClosingEventArgs.Cancel property. The event's CloseReason property will tell you why the event was called (you'd check for CloseReason.UserClosing)

这篇关于VB.NET当用户单击X(关闭程序)超载默认功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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