Error detection

Apr 20, 2012 at 1:17 PM

So far I've built a nice GUI to edit some options for my application. Everything is presented in a simple PropertyControl where I set SelectedObject to the object that should be edited (I have three of these). I have also implemented error checking (using reflections) for the issues not detected by PropertyTools. This is done when the user tries to save his changes. Now, my problem is that I don't know how to make my Apply_button method aware of any issues that may be detected by PropertyTools (e.g. usmall overflow for a port number), without having to manually check them.

Apr 20, 2012 at 1:31 PM

I initially imagined I could do something like myPropertyControl.GetIssues(), and just verify that there were no errors, or otherwise present the user with the errors, or just the fact that there is an error, along with my other error messages.

Coordinator
Apr 20, 2012 at 8:29 PM

Did you implement IDataErrorInfo on your model? 

See http://msdn.microsoft.com/en-us/library/system.componentmodel.idataerrorinfo.aspx

If you edit in a dialog you should also implement IEditableObject

See http://msdn.microsoft.com/en-us/library/system.componentmodel.ieditableobject.aspx

Apr 22, 2012 at 10:14 PM

Well, so far the default checks of PropertyTools (i.e. that my numbers are within ushort), but I might consider those in the future. Right now I am just looking for a quick thing to stop my apply method from saving if there are errors in the default checks.