How do I create a ProperyGrid subcategory?
-
I know that to display a custom control's attribute in a specific category in the PropertyGrid you use:
[Browsable(true), Category("SomeCategory"), Description("Some info....")]
What I would like to do is have one overriding category for my control's attributes (such as "Control Specific") and then have subcategories for more specific things (such as "Colors"). Sort of like under "Appearance" there is "Font". How do I do that? Thanks.
-
I know that to display a custom control's attribute in a specific category in the PropertyGrid you use:
[Browsable(true), Category("SomeCategory"), Description("Some info....")]
What I would like to do is have one overriding category for my control's attributes (such as "Control Specific") and then have subcategories for more specific things (such as "Colors"). Sort of like under "Appearance" there is "Font". How do I do that? Thanks.
In short, you can't define a sub-category. You can have properites be expandable though. In your example, the Appearance property would be of type (say) MyAppearance. MyAppearance type would define it's TypeConverter as ExpandableObjectConverter[^]. Then MyAppearance's properties would be shown in the PropertyGrid (which would include a Font property). This[^] article describes how to use ICustomTypeDescriptor (which allows you to dynamically change what is shown in the PropertyGrid) and ExpandableObjectConverter.
Take care, Tom ----------------------------------------------- Check out my blog at http://tjoe.wordpress.com
-
I know that to display a custom control's attribute in a specific category in the PropertyGrid you use:
[Browsable(true), Category("SomeCategory"), Description("Some info....")]
What I would like to do is have one overriding category for my control's attributes (such as "Control Specific") and then have subcategories for more specific things (such as "Colors"). Sort of like under "Appearance" there is "Font". How do I do that? Thanks.
Hi David, As Tom explained, with the Microsoft PropertyGrid, you can't create subcategories. You can only create kind of container-like properties that you publish with a custom type descriptor. If a commercial product is an option for you, only Smart PropertyGrid.Net is able to create true subcategories. Best regards, Nicolas Cadilhac @ VisualHint Smart PropertyGrid.Net Microsoft PropertyGrid Resource List Free PropertyGrid for MFC Smart FieldPackEditor.Net / DateTimePicker