我试图全面了解如何使用ICustomTypeDescriptor、TypeDescriptionProvider、TypeConverter和UITypeEditor来改变PropertyGrid的显示方式和与对象的接口。
有人能告诉我这是对的,还是我遗漏了任何重要的概念或要点?我只是想弄清楚为什么和什么时候你会使用每一节课。
ICustomTypeDescriptor
在类中实现此接口的ICustomTypeDescriptor.GetProperties()
TypeDescriptionProvider
用于扩展类的现有属性的attribute
A TypeDescriptionProvider通过TypeDescriptionProvider的TypeDescriptionProvider GetTypeDescriptor()方法将ICustomTypeDescriptor返回到该类型的现有属性后面的ICustomTypeDescriptor。
添加到类中的属性
TypeConverter
UITypeEditor
type.
。
因此,ICustomTypeDescriptor是一个TypeDescription提供程序,用于添加/更改/替换对象的整个属性。TypeConverter和UITypeEditor应用于单个属性,并控制这些特定属性的接口方式。
发布于 2009-04-15 06:02:55
调整:
TypeDescriptionProvider- still _replaces_ metadata (not extends)
- can also be added be `TypeDescriptor.AddProvider`
- can be applied per-type as well as per-instance, making it possible to apply to lists without having to implement `ITypedList`
TypeConverter- for `PropertyGrid`, this is also the mechanism used to obtain metadata; note that `ExpandableObjectConverter` simply delegates to `TypeDescriptor.GetProperties`, but this is not always the case
- also responsible for re-creating immutable objects (such as structs) with changes
UITypeEditor- also responsible for painting the preview box in `PropertyGrid`
补充:
IExtenderProvider -附加属性;这可能是您与TypeDescriptionProviderITypedList混淆的地方--广义上是ICustomTypeDescriptor的孪生,但是对于列表;可以避免使用TypeDescriptionProvider和任何IList上的非对象索引器(即public T this[int index] {get;}IListSource )提供数据源和数据之间的间接性;例如,DataTable实现IListSource,在请求时返回DefaultView。
https://stackoverflow.com/questions/749542
复制相似问题