Question

I'm using a PropertyGrid to show custom properties that are exposed through the implementation of ICustomTypeDescriptor.

My objects are setup in a tree structure and values for each property are either set in each object or inherited from parent objects. In the PropertyGrid I want to visually show the user what properties values are set in the selected object, and which are inherited from parent objects.

Right now I am showing every property it two categories. One set shows what the value is set to in the actual object, with a blank field if it not set. The other set shows the property values assigned to the object that are either set in the object, or inherited if not set in the object.

I would like to combine these two groups into one buy showing set properties in regular text, and inherited values in italic text. However, there doesn't seem to be any way to do that through ICustomTypeDescriptor.GetProperties(). And I don't have easy access to the properties of the PropertyGrid since they get created while the program is running.

Was it helpful?

Solution

You can't do italics - but you can do bold; the bold behaviour is determined by the PropertyDescriptor's ShouldSerializeValue; you can wrap PropertyDescriptors via various System.ComponentModel tricks (ICustomTypeDescriptor, TypeConverter or TypeDescriptionProvider) and provide your own PropertyDescriptor.

Alternatively, there are similar grids with more options, such as by VisualHint - see "Property customization" on that page.

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