C#: Insert custom TypeConverter on a property at runtime, from inside a custom UITypeEditor
- by Pedery
I've created a custom UITypeEditor.
Can I possibly insert an attribute that also attaches a TypeConverter to my property from inside the UITypeEditor class?
I've tried the following, but nothing happens, no matter how I twist and turn it:
Attribute[] newAttributes = new Attribute[1];
newAttributes[0] = new TypeConverterAttribute(typeof(BooleanConverter));
Now, the above needs to have the following attached to it somehow:
TypeDescriptor.AddAttributes(context.Instance.PROPERTYNAME, newAttributes);
...but first of all I don't know how to get to the property in question in a generic way, and all code I try just fails. Even if I try to assign the TypeConverter in this manner globally, it fails. (Setting it as an attribute on the property itself works though, just to rule out that the bug is in that part.)