Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ErrorProvider component

Status
Not open for further replies.

696796

Programmer
Aug 3, 2004
218
GB
I am using this componenet to flag blank textboxes etc in my system -

Now i think my code is correct,and i have added the conmponent to the form, it catches the error fine. My problem is that i cannot get the icon to disappear once it is displayed (when i go and fill the txtCarNo and press submit again)

Code:
    Public Sub validateForm2()

        Dim CarNoErrorProvider As New System.Windows.Forms.ErrorProvider
        If txtCarNo.Text = "" Then
            CarNoErrorProvider.SetError(txtCarNo, "Cannot leave textbox blank")
        Else
            CarNoErrorProvider.SetError(txtCarNo, "")

        End If

        Dim SupplierErrorProvider As New System.Windows.Forms.ErrorProvider
        If cboSupplier.SelectedValue = (0) Then
            SupplierErrorProvider.SetError(cboSupplier, "Cannot leave textbox blank")
        Else
            SupplierErrorProvider.SetError(cboSupplier, "")
        End If

    End Sub
 
CarNoErrorProvider.clear doesn't work btw
 
I would bet that it's because you are instantiating new instances of the ErrorProvider each time you validate.

Make the error providers form global, and don't instantiate them every time you validate (only do it if they are equal to nothing).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top