c# - Implementing TypeConverter for handling PropertyGrid exceptions -


i 'm developing winform application , use of propertygrid control. handle exceptions form porpertygrid implemented class derived typeconverter , overwrote various methods including convertfrom check if can convert, example, string integer, , show messagebox if not. problem convertfrom called multiple times when writing incorrect value in property , therefore messagebox displayed several times. idea why happens or how can solve it?

public override object convertfrom(itypedescriptorcontext context, system.globalization.cultureinfo culture, object value) {     if (value string)     {         int result;         if (int.tryparse(value string, out result))             return result;         else         {             messagebox.show("error");         }     }     var def = context.propertydescriptor.attributes.oftype<defaultvalueattribute>().firstordefault();     return def != null ? def.value : 0; } 


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -