ICustomTypeDescriptor, TypeDescriptionProvider, TypeConverter, and UITypeEditor

前端 未结 1 559
甜味超标
甜味超标 2020-12-12 13:41

I\'m trying to get an overall understanding of how you use ICustomTypeDescriptor, TypeDescriptionProvider, TypeConverter, and UITypeEditor to change how a PropertyGrid displ

相关标签:
1条回答
  • 2020-12-12 14:32

    Tweaks:

    • 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

    Additional:

    • IExtenderProvider - appends properties; this may be what you were getting confused with TypeDescriptionProvider
    • ITypedList - broadly the twin of ICustomTypeDescriptor, but for lists; can be avoided by use of TypeDescriptionProvider and a non-object indexer on any IList, i.e. public T this[int index] {get;}
    • IListSource - provides indirection between a data-source and the data; for example, a DataTable implements IListSource, returning DefaultView when requested
    0 讨论(0)
提交回复
热议问题