Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 998
  • Last Modified:

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.
0
Tigger996
Asked:
Tigger996
1 Solution
 
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
Granular recovery for Microsoft Exchange

With Veeam Explorer for Microsoft Exchange you can choose the Exchange Servers and restore points you’re interested in, and Veeam Explorer will present the contents of those mailbox stores for browsing, searching and exporting.

 
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
 
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

Featured Post

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.  

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