Question about PropertyGrid
-
Hello... I have a problem. I try to show all property in my object into a propertyGrid. My class is something like this :
class MyClass
{
public Parent parent = new Parent();
}class Parent
{
public Child child = new Child();
}class Child
{
public string text = "Hello Child";
}If I create a new instance from MyClass and put it in property grid, I can only see a gray text from "Parent". But I cannot go into it, to see the "Child". There are no "+" sign. How to make "Child" also editable in property grid ? Thanks...
-
Hello... I have a problem. I try to show all property in my object into a propertyGrid. My class is something like this :
class MyClass
{
public Parent parent = new Parent();
}class Parent
{
public Child child = new Child();
}class Child
{
public string text = "Hello Child";
}If I create a new instance from MyClass and put it in property grid, I can only see a gray text from "Parent". But I cannot go into it, to see the "Child". There are no "+" sign. How to make "Child" also editable in property grid ? Thanks...
in order to work with that control, you need to define some properties within your class(es), don't you think?
SkyWalker
-
in order to work with that control, you need to define some properties within your class(es), don't you think?
SkyWalker
class MyClass
{
private Parent parent = new Parent();
public Parent ParentInstance
{
get { return parent; }
set { parent = value; }
}
}class Parent
{
private Child child = new Child();
public Child ChildInstance
{
get { return child; }
set { child = value; }
}
}class Child
{
private string text = "Hello Child";
public string Text
{
get { return text; }
set { text = value; }
}
}I change the member variable into properties. It doesn't work also. Probably there are some attribute to make the properties in child class visible...? I can only see "ParentInstance" gray and not editable or clickable....
-
class MyClass
{
private Parent parent = new Parent();
public Parent ParentInstance
{
get { return parent; }
set { parent = value; }
}
}class Parent
{
private Child child = new Child();
public Child ChildInstance
{
get { return child; }
set { child = value; }
}
}class Child
{
private string text = "Hello Child";
public string Text
{
get { return text; }
set { text = value; }
}
}I change the member variable into properties. It doesn't work also. Probably there are some attribute to make the properties in child class visible...? I can only see "ParentInstance" gray and not editable or clickable....
-
class MyClass
{
private Parent parent = new Parent();
public Parent ParentInstance
{
get { return parent; }
set { parent = value; }
}
}class Parent
{
private Child child = new Child();
public Child ChildInstance
{
get { return child; }
set { child = value; }
}
}class Child
{
private string text = "Hello Child";
public string Text
{
get { return text; }
set { text = value; }
}
}I change the member variable into properties. It doesn't work also. Probably there are some attribute to make the properties in child class visible...? I can only see "ParentInstance" gray and not editable or clickable....
Hi, You must explicitely tell the PropertyGrid to show subproperties. To do that, the easiest way is to assign the ExpandableObjectConverter to your Parent and Child classes, like this:
[TypeConverter(typeof(ExpandableObjectConverter ))]
class Parent
{
private Child child = new Child();
public Child ChildInstance
{
get { return child; }
set { child = value; }
}
}[TypeConverter(typeof(ExpandableObjectConverter ))]
class Child
{
private string text = "Hello Child";
public string Text
{
get { return text; }
set { text = value; }
}
}Best regards, Nicolas Cadilhac @ VisualHint Smart PropertyGrid.Net Microsoft PropertyGrid Resource List Free PropertyGrid for MFC Smart FieldPackEditor.Net / DateTimePicker