Setting the BrowsableAttribute at Runtime

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.
 
M

Mark Hurd

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...
 
N

Nathan Sokalski

That sounds pretty simple, but I also need to know which eventhandler to do
it in (Init? PreRender? Load?). Thank you for the help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,121
Latest member
LowellMcGu
Top