我觉得只要属性的类型继承于了Component,那么它就是你所说的可折叠的属性,比如:
public class abc
{
public abc()
{
a=new abcd();
}
private abcd a;
//属性A的左边将显示+
[Browsable(true)]
public abcd A
{
get {return a;}
}
}
public class abcd:Component
{
private int a;
[Browsable(true)]
public int A
{
get {return a;}
set {a=value;}
}
private int b;
[Browsable(true)]
public int B
{
get {return b;}
set {b=value;}
}
}
public class abc
{
public abc()
{
a=new abcd();
}
private abcd a;
//属性A的左边将显示+
[Browsable(true)]
public abcd A
{
get {return a;}
}
}
public class abcd:Component
{
private int a;
[Browsable(true)]
public int A
{
get {return a;}
set {a=value;}
}
private int b;
[Browsable(true)]
public int B
{
get {return b;}
set {b=value;}
}
}
PropertyGrid propertyGrid1;
propertyGrid1=new PropertyGrid();
abc a=new abc();
propertyGrid1.SelectedObject=a;
如果你想让它可以放到工具箱上,在类型abc后加上:Component,象abcd类一样
[Description("设置Title图标的停靠位置"),Category("Title图标布局与外观")]
public DockStyle Title_Icon_Pic_Dock
{
get{return this.Title_Icon_Pic.Dock;}
set{this.Title_Icon_Pic.Dock =value;}
}
[Description("控制Title图标图片在控件内的位置关系"),Category("Title图标布局与外观")]
public PictureBoxSizeMode Title_Icon_Pic_SizeMode
就是你所要的