ErrorProvider Glitch

Hi

I'm running Visual Studio .Net 2003 and I'm having a little problem with the ErrorProvider.

I have a tab control with 2 pages with many textboxes.  I validate what's in the textbox during the validating method.  The ErrorProvider works great.  It puts it's little icons besides all incorrect entries.  When the user updates the form, I call errorProvider.dispose so that it clears all the little red icons.  However, if I click on tab page 2 then come back to tab page 1, all the little red icons appear.  What am I missing?  I'm thinking that it's not disposing of all the errors.  
Any help would be greatly appreciated.
Tigger996Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

testnCommented:
You should clear out the error by setting the text instead of calling Dispose. Dispose will clean up the object not the text.

foreach(Control c in this.Controls)
{
    errorProvider1.SetError(c,"");
}
0
Tigger996Author Commented:
What would the code be for Visual Basic?

0
liebrandCommented:
for each c as control in this.controls
   errorProvider1.seterror(c,"")
next
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tigger996Author Commented:
I have put in the above code. However, when I click my update button,  the errors icons disappear, BUT when I click to a different tab page and come back to the first one, the error icons re-appear.  Does anyone have any ideas?

0
Bob LearnedCommented:
If you are clearing the errors, then the icons should disappear and not come back.  If they are coming back, then you have an event that is setting them again.  Find any lines that SetError, and put a break point there, and check to see if you get there after switching tabs.
0
Tigger996Author Commented:
I have put breakpoints in.  For example I have approx. 20 fields on my form.  When I tab through a couple of them, my errorprovider comes up like it should.  So in that instance, ornly 2 controls have been set with the errorprovider. When I click my update button, I run the above code (now), the icons disappear, I switch tabs, All error fields have the red icon.  But with breakpoints, the validating method dioesn't get touched.  It just kinda happens magically.

 
0
Tigger996Author Commented:
A Little Addition:

After playing around, after the icons appear on their own, I edited the textbox and put in a valid entry, the validating method is called, I set the errorprovider to "", but the icon doesn't go away.
0
Bob LearnedCommented:
I have VB.NET 2003, and I haven't seen this "magical" problem with the ErrorProvider control, but I probably never got into the exact situation that you are in.
0
Tigger996Author Commented:
I can handle that the errorprovider comes up on invalid fields, but when I do put a proper value in, the error provider won't disappear after I switch between tab pages and they re-appear.


0
Bob LearnedCommented:
You're right, there is something strange going on here.  I set up a small test with just a tab control (2 pages), and a few controls, and an error provider.  When I switch tabs the error icons don't reappear.  You might want to set up this kind of test to see if it will work with only a simple set of conditions.
0
Tigger996Author Commented:
Try using bound controls, I'm starting to believe that it has something to do with that.  I'm going to remove all my errorprovider statements and start from scratch.  Maybe I can see when and where it's going wrong. I'll keep you posted.
0
Tigger996Author Commented:
Some more info:

1) Would upgrading to 2003 from 2002 have any differences. Because I think It was working in 2002.  I'm not sure now.

2) I've even set my errorprovider = nothing when I updated the record, and it still shows up if I swtich between tab pages.
0
Bob LearnedCommented:
1)  Since I didn't have 2002, I can't comment on any conversion problems.  My only comment would be 'Maybe'.  I have seen others have minor problems when converting from 2002, but not this problem specifically.

2)  I don't know what implication ErrorProvider = Nothing has.  If there are other references to it, the garbage collector won't dispose of the object.  How do you use the ErrorProvider specifically?  SetError?
0
Tigger996Author Commented:
I tried serError(sender,""), setError(txtbox,""), setError.Dispose()

I think I've narrowed it down to the tab page.  I removed all references to the errorprovider, created a new one, and had it check on 1 field.  Once I switched tab pages after it has been set, it still came back.  Otherwise, if I stayed on the same tab page, it worked perfectly.  

So my own solution, I'm creating my own error checking/displaying class.  

So I guess my next question is, You know how the errorProvider blinks, how could I do that with my picturebox control.?

And when using the picturebox control, is the image embedded in the code so that you don't need the file sitting in the app directory somewhere and have to worry about setting the path?

3rd Is there a way to run through all picturebox controls so that I get rid of my icon?

These are pretty easy questions, I'm kinda running late on this project.  So whoever can help me make my class work the way I want, I'll reward all the points to them.

0
Bob LearnedCommented:
(1) Blinking picturebox:

Timer control:  Set interval to blink rate in the milliseconds.
Timer_Tick event:  Toggle the visible property for the picture box

(2) The image for the picture box is stored in .resx file, so it doesn't depend on the physical disk location.

(3) Looping through picture boxes:

     Dim control As Control
     Dim picture As PictureBox
 
     For Each control In Me.TabControl1.Controls

         If TypeOf control is PictureBox Then
             picture = CType(control, PictureBox)
             picture.Image = Nothing
         EndIf

     Next control
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Tigger996Author Commented:
1) How can I tell me class sub to look at a tabcontrol ?  I was just passing the form (Me). And that doesn't see what's in the tabpages.

2)Would I have to loop through each tab page and form?

Thanks for all your help, you don't know how much I appreciate it.



0
Tigger996Author Commented:
Ok This is getting frustrating.  I've tried passing this, me.tabpage1.controls.  All the function see's is the groupboxes on my tab control page, not what's in the groupboxes.  Is there a way to check all controls on the WHOLE form?

0
Bob LearnedCommented:
The Controls property only shows you the controls that it owns.  So, if you want the controls for the group box, then:

For Each control In Me.GroupBox1.Controls
0
Tigger996Author Commented:
Thanks TheLearnedOne.  You were a GREAT help. Keep watching for my posts. :)  I'm still pretty new to .Net and am amazed that I have a functioning database program.  

Thanks again.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

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.