I want to avoid placing an EditorAttribute on every instance of a certain type that I’ve written a custom UITypeEditor for.
I can’t place an EditorAttribute on the type because I can’t modify the source.
I have a reference to the only PropertyGrid instance that will be used.
Can I tell a PropertyGrid instance (or all instances) to use a custom UITypeEditor whenever it encounters a specific type?
Here is an MSDN article that provides are starting point on how to do this in .NET 2.0 or greater.
You can usually associate editors etc at runtime via
TypeDescriptor.AddAttributes. For example (theBarproperty should show with a “…” that displays “Editing!”):