首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ICustomTypeDescriptor,TypeDescriptionProvider,TypeConverter和UITypeEditor

ICustomTypeDescriptor,TypeDescriptionProvider,TypeConverter和UITypeEditor
EN

Stack Overflow用户
提问于 2009-04-14 22:05:03
回答 1查看 10K关注 0票数 39

我试图全面了解如何使用ICustomTypeDescriptor、TypeDescriptionProvider、TypeConverter和UITypeEditor来改变PropertyGrid的显示方式和与对象的接口。

有人能告诉我这是对的,还是我遗漏了任何重要的概念或要点?我只是想弄清楚为什么和什么时候你会使用每一节课。

ICustomTypeDescriptor

在类中实现此接口的ICustomTypeDescriptor.GetProperties()

  • 覆盖类的本机属性,并将其替换为由PropertyDescriptors返回的PropertyDescriptors。

TypeDescriptionProvider

用于扩展类的现有属性的attribute

  • The TypeDescriptionProvider

A TypeDescriptionProvider通过TypeDescriptionProvider的TypeDescriptionProvider GetTypeDescriptor()方法将ICustomTypeDescriptor返回到该类型的现有属性后面的ICustomTypeDescriptor。

  • A PropertyGrid将显示通过反射找到的类的属性,以及通过TypeDescriptionProvider

添加到类中的属性

TypeConverter

  • 通过使用一个用于在属性网格中显示/编辑的复杂类型和基本类型之间转换的PropetyGrid来在
  • 之间进行转换。

UITypeEditor

type.

  • Associated

  • 定义了一个自定义编辑器,用于通过属性操作复杂

  • 的属性。

因此,ICustomTypeDescriptor是一个TypeDescription提供程序,用于添加/更改/替换对象的整个属性。TypeConverter和UITypeEditor应用于单个属性,并控制这些特定属性的接口方式。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2009-04-15 06:02:55

调整:

  • TypeDescriptionProvider

代码语言:javascript
复制
- 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

代码语言:javascript
复制
- 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

代码语言:javascript
复制
- also responsible for painting the preview box in `PropertyGrid`

补充:

  • IExtenderProvider -附加属性;这可能是您与TypeDescriptionProvider
  • ITypedList混淆的地方--广义上是ICustomTypeDescriptor的孪生,但是对于列表;可以避免使用TypeDescriptionProvider和任何IList上的非对象索引器(即public T this[int index] {get;}
  • IListSource )提供数据源和数据之间的间接性;例如,DataTable实现IListSource,在请求

时返回DefaultView

票数 38
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/749542

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档