The blog has moved to a new address. The blog is now located at http://devintelligence.com

Saturday, January 27, 2007

PropertyGrid: How to group properties by category?

Use Category attribute .Note that properties without the attribute will be shown uder category named "Misc"

[DisplayName("First Name")]
[Description(
"First Name of the person")]
[Category(
"Personality")]
public string FirstName
{
get
{
return _FirstName;
}
set
{
_FirstName
= value;
}
}


[Category(
"Specific")]
public Color HairColor
{
get
{
return _HairColor;
}
set
{
_HairColor
= value;
}
}

source(russian)

2 comments:

Anonymous said...

how does one remove the default category Misc. eg., create a poerty gridwtih only properties listed

Taras said...

Try to press "A-B" button - in this mode the property grid doesn't show categories .The code below presents
how to switch the mode programmatically .


// in this mode the categories will not be shown
propertyGrid1.PropertySort = PropertySort.NoSort;
// also you can hide the top property grid toolbar
propertyGrid1.ToolbarVisible = false;


Regards