使用
<System.ComponentModel.TypeConverter(GetType(System.ComponentModel.ExpandableObjectConverter))> _
一类的声明(这是另一个类的属性),它由一些属性。
我装入只是这个类的一个实例...
PropertyGrid1.SelectedObject = oColumn
很显然,我不想手工打造code PropertyGrid中,我知道该怎么做。
但这里有一个问题。根据一个属性值,某些其它性能不应该是可见的,因为虽然我已经采用的
&LT; System.ComponentModel.Browsable(假)&GT; _
在属性声明属性。
反正有做到这一点编程,无需处理属性网格的所有建筑手动>
解决方案如果你希望一个gridItem.Hide(),那么,答案是否定的。只有这样,才能实现,在MS PropertyGrid中是动态发布通过类型转换器或自定义类型说明符的getProperties方法的属性(即实现了ICustomTypeDescriptor)。我会先尝试与类型转换器(expecially如果你要检查的属性值都在同一水平),有较少的代码做的。
Using
<System.ComponentModel.TypeConverter(GetType(System.ComponentModel.ExpandableObjectConverter))> _
on the declaration of a class (which is a property of another class) that consists of a number properties.
I load an instance of this class with simply ...
PropertyGrid1.SelectedObject = oColumn
Obviously I don't want to manually build the propertygrid in code, I know how to do that.
But here's the problem. Depending on the value of a property, certain other properties should not be visible, as though I'd used the
<System.ComponentModel.Browsable(False)> _
attribute on the property declaration.
Is there anyway to do this programmatically, without having to handle all the building of the property grid manually>
解决方案if you were hoping for a gridItem.Hide() then, the answer is no. The only way to achieve that in the MS PropertyGrid is to dynamically publish your properties through the GetProperties method of a TypeConverter or custom type descriptor (that implements ICustomTypeDescriptor). I would try first with the TypeConverter (expecially if the property values you want to check are at the same level), there is less coding to do.