I need to enable editing properties of arbitrary objects (the type of object is only known at run-time). I created the following class:
public class Camera
{
[TypeConverter(typeof(ExpandableObjectConverter))]
public object Configuration
{
get
{
return configuration;
}
set
{
configuration = value;
}
}
public Class1 a;
[TypeConverter(typeof(ExpandableObjectConverter))]
public Class1 A
{
get
{
return a;
}
set
{
a = value;
}
}
}
After selecting object “Camera”, I can see the property of Class1 on PropertyGrid, but I can’t see the property of object “Configuration”. How can I fix this problem?
My assumption was that your form becomes visible before the Configuration property was assigned. You didn’t supply enough code to see if that was the case. In order to test out my concern, I created two configuration objects:
and
I modified your camera class to look like this:
I then created a form with a PropertyGrid and two Button instances. I configured the form interactions like this:
The startup view looks like this:
After clicking the first button:
After clicking the second button:
If you remove the refresh, the property grid does not work correctly. The alternative is to supply an interface with INotifyPropertyChanged on your classes and properties.