The Microsoft Property Grid control is great for displaying properties of your types, but using it for displaying your own custom property lists is slightly more tricky. Included is an example and source code for implementing your own PropertyDescriptor class for use with the control.
Download
PropertyGridDemo.zip
The Code
There are 3 classes that you'll ned to implement to make use of the functionality provided by the PropertyGrid control:
- A CustomProperty class, which in this case holds a category, name and value (and some other attributes that are useful)
- A CustomPropertyDescriptor class, which inherits System.Component.PropertyDescriptor. This class 'extracts' the necessary information from your custom property class for the grid to display.
- A CustomPropertyList, which inherits from List<CustomProperty> as well as inherits ICustomTypeDescriptor. This is the class that you will use as the datasource for the property grid.
Here is a snippet of the CustomProperty class; I've added an IsVisible and an IsReadOnly property that we can use in the grid.
public class CustomProperty
{
public CustomProperty(string category, string name, string value, bool isVisible, bool isReadOnly)
{
Category = category;
Name = name;
Value = value;
IsVisible = isVisible;
IsReadOnly = isReadOnly;
}
public string Category { get; set; }
public string Name { get; set; }
public string Value { get; set; }
public bool IsVisible { get; set; }
public bool IsReadOnly { get; set; }
}
The other two classes included in the demo project are pretty straight forward, so download it and have a look. The end result is something like this:

The "Details, Stuff and Things" sections come from the Category property in your custom class, and the name and values from their respective properties.