List of PropertyGrid Attributes

廉价感情. 提交于 2019-12-09 05:14:38

问题


I can't find any list of the available attributes for the PropertyGrid in C#, do you know where I can find one?

Thanks.


回答1:


The attributes that impact PropertyGrid are indirect: the interesting code is the TypeDescriptor which provides the PropertyDescriptor implementation. However, this van be overruled by ICustomTypeDescriptor or TypeDescriptionProvider.

However, if we assume the default rules, the key attributes in play are:

  • [DisplayName(...)]
  • [Description(...)]
  • [Category(...)]
  • [TypeConverter(...)]
  • [ReadOnly(...)]
  • [Browsable(...)]
  • [DefaultValue(...)]
  • [Editor(...)]

Some other things are detected by patterns such as the presence of a ShouldSerialize{name} or Reset{name} method.




回答2:


i would also add

RefreshPropertiesAttribute

NotifyParentPropertyAttribute




回答3:


I would also add "MergableAttribute". This is useful for prevent property-grid to group identity fields, since if you select multiple objects, you don't want to be able to modify the "Name" property (for example) of the objects using property-grid, since it must remain unique per object...



来源:https://stackoverflow.com/questions/15051298/list-of-propertygrid-attributes

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!