Search code examples
c#propertiesconditional-statementsbrowsable

Conditional "Browsable" Attribute



Is there a way to make a "Browsable" attribute conditional, so the property that applies it will sometimes appear in the properties page and sometimes not?
thanks :)


Solution

  • There is no easy way.

    You can possibly work this out by implementing ICustomTypeDescriptor. Here is a good article about implementing ICustomTypeDescriptor.

    Or you can associate your own ControlDesigner with your class and override the PreFilterProperties method to add or remove properties viewed in the property grid.

    Removing certain properties from property grid.