Question

Is it possible to add/remove properties in a Windows Forms PropertyGrid control depending on the value of another boolean property?

As an example, suppose the selected object has a boolean ShowTitle property. I need to show TitleFont and TitleColor properties only if ShowTitle is set to true. Also, it would be great if the TitleFont and TitleColor properties were children of the ShowTitle property.

If this is not possible, then what other options do I have apart from creating a custom editor?

Update:

From what I understand, it seems that the PropertyGrid allows us to do this...

Expandable property

...but not this (below image is just a mock-up) ...

Dropdown (mock-up)

Was it helpful?

Solution

What you could do is reuse the DynamicTypeDescriptor class described in my answer to this question here on SO: PropertyGrid Browsable not found for entity framework created property, how to find it?

There is also another good one base ond the same utility class: Optimize class for PropertyGrid

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top