Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List of PropertyGrid Attributes

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

Thanks.

like image 874
Phito Avatar asked Feb 24 '13 11:02

Phito


3 Answers

i would also add

RefreshPropertiesAttribute

NotifyParentPropertyAttribute

like image 43
stefano m Avatar answered Oct 15 '22 01:10

stefano m


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.

like image 96
Marc Gravell Avatar answered Oct 15 '22 01:10

Marc Gravell


If PropertyGrid is from Xceed Extended.Wpf.Toolkit it also count on System.ComponentModel.DataAnnotations.Display attribute.

[Display(Name="", Description="", Order=1)]

With it you can provide:

  1. Name overrides [DisplayName(...)]
  2. Description possible overrides [Description(...)]
  3. Order in the list (unique, I do not know other ways to provide order)
  4. there are other few (GroupName, Prompt, ShortName, ResourceType, AutoGenerateField, AutoGenerateFilter), but I did not test them and can say ho they works in property grid...
like image 1
Andrey the Autobot Avatar answered Oct 15 '22 03:10

Andrey the Autobot