当用户单击“X”图标以关闭应用程序或用户单击关闭应用程序的应用程序中的按钮时,是否有一种简单的方法可以禁用所有表单验证? 我发现了这个,但它在C#中.你能把它转换成VB.Net编码
我发现了这个,但它在C#中.你能把它转换成VB.Net编码吗?
http://geekswithblogs.net/dapostolov/archive/2009/06/14/the-validating-event-can-prevent-a-form-closing-properly.aspx
找到了!我将此代码放在按钮单击处理程序中:
' Disable validation on the form. '-------------------------------- Me.AutoValidate = System.Windows.Forms.AutoValidate.Disable
当我再次调用表单时,我将其用于名为objFormParents的表单对象:
' Reset validation on this form because the user may have closed it before. '-------------------------------------------------------------------------- objFormParents.CausesValidation = True
我发现这在互联网上处理点击“X”图标:
' This will allow the user to close the form without the worry of controls doing validation from "X". '---------------------------------------------------------------------------------------------------- Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) Select Case ((m.WParam.ToInt64() And &HFFFF) And &HFFF0) Case &HF060 ' The user chose to close the form. Me.AutoValidate = System.Windows.Forms.AutoValidate.Disable End Select MyBase.WndProc(m) End Sub