florin,
If you want to add attributes to a type at runtime, then you really
can't, as a type is supposed to be static throughout the lifetime of an app,
and that includes attributes.
However, the PropertyGrid uses Type Descriptors, which have a more
limited context, and will give you what you want. Basically, you want to
create a shim class which implements the ICustomTypeDescriptor interface,
and return the property descriptors, method descriptors, and all the as well
as the Attributes that are associated with it.
Check out the .NET matters column in MSDN Magazine from April and May
2005 for an article which will help you with what you are looking for:
http://msdn.microsoft.com/msdnmag/is...04/NETMatters/ http://msdn.microsoft.com/msdnmag/is...05/NETMatters/
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"florin" <df****@gmail.comwrote in message
news:11**********************@19g2000hsx.googlegro ups.com...
>
hi
Is there a "simple" way to add attributes to a class/property at
runtime?
What I try to do is set the default editor for a class/property at
runtime (I know I can set this very easy by decorating the class/
property code), but I would like to do this at runtime.
Is there another way to tell the PropertyGrid what editor to use for a
class/property ?
thanks,
florin