How to change an attribute at runtime

Hi there,

I need to change the "Browsable" attribute for one of my class' properties
at runtime from "true" to "false". The only way I can see how to do it is
via "ICustomTypeDescriptor.GetProperties()" which means implementing the
latter interface on my class, creating a customized "PropertyDescriptor",
etc. Basically a lot of work for something so simple. Is there an easier way
to do this. Thanks.




Answer this question

How to change an attribute at runtime

  • bessermt

    What are you trying to do A class attribute is an attribute of a class, not an instance of a class; "runtime" really doesn't have a bearing.

  • cdun2

    Thanks very much. Unfortunately, it has to go through the same painful process I was hoping to avoid. While I can certainly leverage this code for my own needs (with improvements), MSFT really needs to build a better mousetrap. It shouldn't take days of research to accomplish something so simple. Anyway, thanks again (appreciated).

  • caltex

    This project might be useful...


  • TCSC

    I'm trying to change the "Browsable" attribute for a property at runtime (based on runtime conditions). After days of painful research, I now have the knowledge to accomplish this but unless I've missed something obvious, the process is unacceptably complicated and error-prone (I've tagged my class with the "TypeDescriptionProvider" attribute and introduced a "CustomTypeDescriptor" derivative which adjusts the "Browsable" attribute accordingly). If you know of a trivial way to do it I'd certainly appreciate some guidance. Thanks very much.

  • How to change an attribute at runtime