List of PropertyGrid Attributes

前端 未结 4 1050
眼角桃花
眼角桃花 2021-02-05 09:16

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

Thanks.

相关标签:
4条回答
  • 2021-02-05 09:34

    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...

    0 讨论(0)
  • 2021-02-05 09:38

    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.

    0 讨论(0)
  • 2021-02-05 09:46

    i would also add

    RefreshPropertiesAttribute

    NotifyParentPropertyAttribute

    0 讨论(0)
  • 2021-02-05 09:54

    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...
    0 讨论(0)
提交回复
热议问题