Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

ErrorProvider Glitch

Posted on 2003-12-02
19
Medium Priority
?
993 Views
Last Modified: 2007-12-19
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.
0
Comment
Question by:Tigger996
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
19 Comments
 
LVL 18

Expert Comment

by:testn
ID: 9857693
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
 

Author Comment

by:Tigger996
ID: 9857739
What would the code be for Visual Basic?

0
 
LVL 15

Expert Comment

by:liebrand
ID: 9859413
for each c as control in this.controls
   errorProvider1.seterror(c,"")
next
0
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 

Author Comment

by:Tigger996
ID: 9860978
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
 
LVL 96

Expert Comment

by:Bob Learned
ID: 9861032
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
 

Author Comment

by:Tigger996
ID: 9861099
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
 

Author Comment

by:Tigger996
ID: 9862356
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
 
LVL 96

Expert Comment

by:Bob Learned
ID: 9866182
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
 

Author Comment

by:Tigger996
ID: 9869211
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
 
LVL 96

Expert Comment

by:Bob Learned
ID: 9869684
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
 

Author Comment

by:Tigger996
ID: 9870023
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
 

Author Comment

by:Tigger996
ID: 9870852
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
 
LVL 96

Expert Comment

by:Bob Learned
ID: 9874188
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
 

Author Comment

by:Tigger996
ID: 9876048
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
 
LVL 96

Accepted Solution

by:
Bob Learned earned 2000 total points
ID: 9876679
(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
 

Author Comment

by:Tigger996
ID: 9876731
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
 

Author Comment

by:Tigger996
ID: 9876802
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
 
LVL 96

Expert Comment

by:Bob Learned
ID: 9876837
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
 

Author Comment

by:Tigger996
ID: 9876886
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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

610 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