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

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

问题描述

当用户在基于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。关闭事件...但由于它是一个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.

推荐答案

如果您想在表单关闭之前进行一些额外的清理,请在表单的表单关闭事件

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

此事件还允许您通过事件的 FormClosingEventArgs.Cancel属性。活动的 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)

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

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