为什么SomeClass.ClassField.StructField
属性在 a 中没有变化propertyGrid
?看来,实例更改后propertyGrid
不会调用。但是相同的代码可以很好地与而不是.SomeClass.ClassField.set
SomeStruct
Point
SomeStruct
[TypeConverter(typeof(ExpandableObjectConverter))]
public struct SomeStruct
{
private int structField;
public int StructField
{
get
{
return structField;
}
set
{
structField = value;
}
}
public override string ToString()
{
return "StructField: " + StructField;
}
}
[TypeConverter(typeof(ExpandableObjectConverter))]
public sealed class SomeClass
{
public SomeStruct ClassField
{
get;
set;
}
}
...
var someClass = new SomeClass
{
ClassField = new SomeStruct
{
StructField = 42
}
};
propertyGrid.SelectedObject = someClass;