VB.NET中,如何防止用户关闭程序时触发表单验证?
- 内容介绍
- 文章标签
- 相关推荐
本文共计325个文字,预计阅读时间需要2分钟。
当用户单击X图标以关闭应用程序或用户单 击关闭按钮时,在应用程序中,是否存在一种简单的方法可以禁用所有表单验证?我发现了一个,但它在C语言中。
当用户单击“X”图标以关闭应用程序或用户单击关闭应用程序的应用程序中的按钮时,是否有一种简单的方法可以禁用所有表单验证?我发现了这个,但它在C#中.你能把它转换成VB.Net编码吗?
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
本文共计325个文字,预计阅读时间需要2分钟。
当用户单击X图标以关闭应用程序或用户单 击关闭按钮时,在应用程序中,是否存在一种简单的方法可以禁用所有表单验证?我发现了一个,但它在C语言中。
当用户单击“X”图标以关闭应用程序或用户单击关闭应用程序的应用程序中的按钮时,是否有一种简单的方法可以禁用所有表单验证?我发现了这个,但它在C#中.你能把它转换成VB.Net编码吗?
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

