I'm customizing how an object type is displayed in a PropertyGrid
by implementing ICustomTypeDescriptor
. I'm allowing the user to create their own custom properties that are stored in a single dictionary of keys and values. I'm able to create all the PropertyDescriptors
for these values and view them in the property grid. However, I also want to show all the default properties that otherwise would have shown if the PropertyGrid
was populated through reflection rather than my override ICustomTypeDescriptor.GetProperties
method.
Now I know how to get the type of the object, and then GetProperties()
, but this returns an array of PropertyInfo
not ProperyDescriptor
. So how can I convert the PropertyInfo
object of the type into PropertyDescriptor
objects to include into my collection with the custom PropertyDescriptors
?
//gets the local intrinsic properties of the object
Type thisType = this.GetType();
PropertyInfo[] thisProps = thisType.GetProperties();
//this line obviously doesn't work because the propertydescriptor
//collection needs an array of PropertyDescriptors not PropertyInfo
PropertyDescriptorCollection propCOl =
new PropertyDescriptorCollection(thisProps);