I have created a class to display in a PropertyGrid
which contains another class; I would like this class to be expandable so I tried adding the [TypeConverter(typeof(ExpandableObjectConverter))]
but it doesn't seem to work. Here is a simple example I tried:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.propertyGrid1.SelectedObject = new Class1();
}
}
public class Class1
{
string name;
public string Name
{
get { return this.name; }
set { this.name = value; }
}
Class2 class2;
public Class2 Class2
{
get { return this.class2; }
set { this.class2 = value; }
}
}
[TypeConverter(typeof(ExpandableObjectConverter))]
public class Class2
{
string stuff = "none";
public string Stuff
{
get { return this.stuff; }
set { this.stuff = value; }
}
}
When displayed in the property grid, the Class2
property of the Class1
instance isn't expandable. Any idea on why this isn't working?
Thanks!