Is it only possible to add categories to the .NET PropertyGrid by annotating my data class with attributes like CategoryAttribute
?
You can use the CategoryAttribute
. The documentation states:
A new category can be created for any name by specifying the name of the category in the constructor for the
CategoryAttribute
.
Example:
[
Category("MyCategory"),
Description("Specifies something")
]
public string Something { //... }
Doing this with ICustomTypeDescriptor and your own PropertyDescriptor class is quite easy and does not involve so much code.
This article Customized display of collection data in a PropertyGrid describes how to do this in detail. For adding categories you would also need to override the Category property in your PropertyDescriptor class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With