解决方法
找到了!
我将此代码放在按钮单击处理程序中:
- ' 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