c# - TypeConverter IsValid not fireing -


i want implement input validation on propertygrid. i've figured out need typeconverter , throw exception in convertfrom method. works fine except shows standard "message box". wish show own. according msdn exception catched in isvalid method. i've tried override thing there doesn't fire.

my code:

public class parameternameconverter : typeconverter {     public override object convertfrom(itypedescriptorcontext context, cultureinfo culture, object value)     {         debug.print("convertfrom");         if (convert.tostring(value).contains(" "))         {             throw new notsupportedexception("invalid input");         }         return value;     }      public override bool isvalid(itypedescriptorcontext context, object value)     {         messagebox.show("invalid input");         return false;     } } 

this code isvalid() microsoft reference source. can see isvalid() calls convertfrom() , try catches it. need perform similar operation calling own convertfrom() method own isvalid() method, , handle exception. if don't override isvalid() base method isvalid() silently eat exception , return standard false response.

although sounds me isvalid() method never being called @ if you're not seeing own message box pop example code? that's different question :p


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -