本文介绍了红色"X"点击表格的处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人知道一种简单的方法来处理红色"X"(位于右上角)单击事件吗?我做了一些研究,但是到目前为止,我发现所有用户诱发"表单都可以使用的解决方案(例如,包括按下已添加到表单的按钮). 有没有办法只处理窗口红色"x"点击?谢谢.
Does anyone know of an easy way to handle the red 'X' (in top right corner) click event? I done a bit of research, but solutions I have found so far work for all 'user-induced' form closes (eg, including pressing a button that has been added to the form). Is there a way to handle only a window red 'x' click? Thanks.
推荐答案
e.Cancel = true或e,Cancel = false,具体取决于您要执行的操作
e.Cancel = true or e,Cancel = false depending on what you want to do
Imports System.ComponentModel
Public Class Form1
Private Sub Form1_Closing(sender As Object, e As CancelEventArgs) Handles Me.Closing
If MessageBox.Show("Exit", "Question", MessageBoxButtons.YesNo) = DialogResult.Yes Then
' they decided to exit so let them
Else
e.Cancel = True
End If
End Sub
End Class
这篇关于红色"X"点击表格的处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!