How do I halt validation on controls on a form if the user presses a cancel button on that form?
Private Sub Wizard1_CancelButtonClick(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles Wizard1.CancelButtonClick
Try
If MessageBox.Show("You want to cancel?", "Cancel Wizard", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
Me.Close()
End If
Catch
MsgBox("There is an error")
End Try
End Sub
Trouble is is that I have a textbox on the form that validates user input
Private Sub Dont_Leave_empty(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles NAMETextBox.Validating, ADDRESSTextBox.Validating
If Me.Table1BindingSource.Current IsNot Nothing And sender.Text = String.Empty Then
'Perform validation here.
MessageBox.Show(" You cannot leave this field blank", "Required Field", MessageBoxButtons.OK, MessageBoxIcon.Warning)
e.Cancel = True
Else
sender.Text = sender.Text.Trim()
End If
And this won't allow me to either cancel the user input or close the form
