VB.NET overload default functionality when user clicks the X (Close Program)(当用户单击 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.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.
推荐答案
如果您想在表单关闭前做一些额外的清理工作,请在表单的 表单关闭事件.
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 重载默认功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:当用户单击 X(关闭程序)时,VB.NET 重载默认功能


基础教程推荐
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01