• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1378
  • Last Modified:

In VB.NET how do you clear the Error Provider Icon from a form once it has been displayed?

I have this code:

Dim err1 as New ErrorProvider

If TextBox1.Text = ""

e.Cancel = True
err1.SetError(TextBox1, "Please Enter A Name")


e.Cancel = False
err1.SetError(TextBox1, "")

End If

But what I want to know is how you clear the icon, if the user leaves the Textbox blank and then hits tab the error provider ICON is placed on the form next to the
Textbox control, but then if they enter a valid value and hit tab the icon stays next to the box.  I don't want my users to think that there is still a problem.

I have the above code in the "Validating" event for the textbox.
1 Solution
This is because you are creating a new ErrorProvider object each time you validate. You need to create the error provider object at the form level (like Form_Load) and then use it in your Validating event.

UberDeveloperAuthor Commented:
Great, Thanks, I didn't even think about that.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now