List of PropertyGrid Attributes

Phito picture Phito · Feb 24, 2013 · Viewed 13k times · Source

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

Thanks.

Answer

Marc Gravell picture Marc Gravell · Feb 24, 2013

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.