Setting the BrowsableAttribute at Runtime

  • Thread starter Thread starter Nathan Sokalski
  • Start date Start date
N

Nathan Sokalski

I have a class that I am writing in which I want to set the
BrowsableAttribute of a Property inherited from it's base class at runtime.
How and where would I do this? Thanks.
 
Nathan Sokalski said:
I have a class that I am writing in which I want to set the
BrowsableAttribute of a Property inherited from it's base class at
runtime. How and where would I do this? Thanks.

If you're building the type at runtime, you need to call
PropertyBuilder.SetCustomAttribute with a CustomAttributeBuilder you've
created with the Attribute you want.

Otherwise you can't change a compiled type at runtime.

You may however be able to use ComponentModel.TypeDescriptionProvider to
fake what you want, depending upon where you need the functionality.
Don't have time to explain this further now...
 
That sounds pretty simple, but I also need to know which eventhandler to do
it in (Init? PreRender? Load?). Thank you for the help.
 
Back
Top