Search code examples
c#winformspropertygrid

how to filter propertygrid deeper


I need to use propertygrid in my project and I need to filter the attributes that will be shown. I found a way to filter the propertygrid by category but I need to go deeper when filtering it.

here is the code which only displays the "Appearance" category. But I need to disable some attributes under the "Appearance" like "BackColor"

Attribute myfilterattribute = new CategoryAttribute("Appearance");
pg_1.BrowsableAttributes = new AttributeCollection(new Attribute[] { myfilterattribute });

how can I filter out the Backcolor as well?


Solution

  • If you want to disable this props statically, e.g. at compile time, you can try this approach. Set them unvisible a run time is more complex, so take a look for dynamic property setting.