I'm wondering in general how one goes about troubleshooting problems with the ErrorProvider control.
I've added some business rules to my bound objects, and the rules are working great. The object is flagged as invalid and CSLA throws an exception if you try to save it.
However, the ErrorProvider might as well not even be there. I've looked at the ErrorProvider designer code and compared to ProjectTracker, and it looks almost identical.
Also interesting is that when doing "in cell" editing with an ERLB bound to a DevExpress XtraGrid, it doesn't show the errors either. However, if the rule malfunctions and throws an exception, the DevExpress grid shows that clearly with it's own ErrorProvider control.
I've never had an issue with it... You have a bindingSource control on your form correct? You set the DataSource property of the bindingSource to your CSLA object, the data bindings of all your controls are set to the bindingSource and the appropriate text property, and the DataSource of the errorProvider itself is set to the bindingSource correct?
Did you add the BindingSourceRefresh control as well? Make sure the new property that is added to your bindingSource (ReadvaluesOnChange) is set to "true".
Not sure what else to check.
Ken
KKoteles:I've never had an issue with it... You have a bindingSource control on your form correct? You set the DataSource property of the bindingSource to your CSLA object, the data bindings of all your controls are set to the bindingSource and the appropriate text property, and the DataSource of the errorProvider itself is set to the bindingSource correct?
*Exactly* -- and the bindings themselves work like a champ. Moreover, the broken rules collection of the bound object is updated as soon as you leave the field with the bad value, but the error provider is silent.
This is why I'm mystified.
So, when you're working with a "black box" like the ErrorProvider and it simply doesn't work once you've deskchecked everything, how do you go about figuring out why it's not working? Is there some event you can hook? Is there some debuggable ErrorProvider-like control out there that you can substitute?
Take a look at this thread:
http://forums.lhotka.net/forums/thread/18041.aspx
I created an ErrorWarnInfoProvider that 'wraps' the ErrorProvider and allows for displaying warnings and informational details associated with a CSLA object. It might give you some insight into what the ErrorProvider itself is trying to use. There are a couple of bugs I fixed since I last posted, but no one seemed interested. If you are interested in the latest version (it fixes a bug where it now recurses through controls that contain controls) let me know and I can update it again. If that doesn't help, then you can try this site:
http://www.aisto.com/roeder/dotnet/
By using reflector you can see exactly what ErrorProvider is doing internally. You can't debug it (as far as I know), but at least you can get an idea of what it is doing.
Ken
KKoteles:...There are a couple of bugs I fixed since I last posted, but no one seemed interested. If you are interested in the latest version (it fixes a bug where it now recurses through controls that contain controls) let me know and I can update it again. ...
Yes, we definitely use nested controls, so I'd be interested in the related fixes. Thanks.
Copyright (c) Marimer LLC