防止表格关闭? [英] Prevent form from closing?
本文介绍了防止表格关闭?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图让用户选择是否真的要关闭表单,以防他们不小心单击X按钮.在应用程序询问他们是否要关闭它的地方,当我单击是"时,它就会关闭.但是,我应该在否"事件处理程序中添加什么,以使其停止关闭表单?
到目前为止,我的代码位于Form(Form_Closing)事件中.表格即可卸载.
嗨!我已经解决了这个问题
使用此代码:
私有 子 FrmMDI_FormClosing( ByVal 发件人 As 对象, ByVal e As System.Windows.Forms.FormClosingEventArgs)句柄 我 .FormClosing Dim 标记 As 整数 标记=(MsgBox(" ,vbInformation + vbOKCancel," )) 如果标志= 2 >然后 e.Cancel = 1 结束 结束 子
解决了您的问题.
谢谢你. :)
I''m trying to allow the user to choose whether or not they really want to close the form, in case they accidentally click the X button. I have it where the application asks whether they want to close it, and when they click "Yes", it closes. But, what should I put in the "No" event handler so that it stops the form from closing?
The code that I have so far is in the Form''s (Form_Closing) event.
解决方案
Try settingCancel = True
in theClosing
event to prevent the form from unloading.
Hi! I have the solution of this Problem
Use This Code :
Private Sub FrmMDI_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing Dim Flag As Integer Flag = (MsgBox("Are you sure you want to exit ? ", vbInformation + vbOKCancel, "Exit")) If Flag = 2 Then e.Cancel = 1 End End Sub
And Your Problem is Solved.
Thank you. :)
这篇关于防止表格关闭?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文