Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27209

VS 2010 Form is still Validating

$
0
0
I am having some trouble with the Validating event on a form.

Here is my code to show the problem:

Code:

    Private Sub TextBox1_Validating(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles TextBox1.Validating
        If TextBox1.Text = "" Then
            e.Cancel = True
            MsgBox("Please enter some text")
        End If
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Me.AutoValidate = False
        Me.Close()
    End Sub

I have also tried:

Code:

CausesValidation = False
If I try and close the form by clicking the Button_1, the form does not close. Why would this be? It seems that the Validation is still turned on. How can I turn this off?

Viewing all articles
Browse latest Browse all 27209

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>