Solved

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

Posted on 2004-04-05
2
1,291 Views
Last Modified: 2008-05-29
I have this code:

Dim err1 as New ErrorProvider


If TextBox1.Text = ""

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

Else

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.
0
Comment
Question by:UberDeveloper
2 Comments
 
LVL 6

Accepted Solution

by:
KarunSK earned 500 total points
ID: 10761151
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.

Karun.
0
 
LVL 2

Author Comment

by:UberDeveloper
ID: 10761165
Great, Thanks, I didn't even think about that.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now