简体   繁体   中英

Category Ordering In Xceed PropertyGrid

I am using PropertyGrid of Xceed to display characteristics of some elements. There are different categories for element like: General, Advanced, Others, Special. Here, I found that the Xceed's propertygrid sorts the category as well as property in alphabetical order. I was able to sort the properties inside the categories by using [PropertyOrder(n)] . I also wanted to sort the categories so, I tried using CategoryOrder like [CategoryOrder("General", 0)] but it shows the following error:

Error 2 Attribute 'CategoryOrder' is not valid on this declaration type. It is only valid on 'class' declarations.

Am I using it wrong? The code provide below is just a sample to show how I am using this.

[Category("General")]
[CategoryOrder("General", 0)]
[DisplayName("XValue")]
[Description("Value of X-Coordinate")]
[ReadOnly(true)]
[PropertyOrder(1)]

[Category("Advanced")]
[CategoryOrder("Advanced", 1)]
[DisplayName("Collision")]
[Description("Collision")]
[ReadOnly(true)]
[PropertyOrder(1)]

[Category("Others")]
[CategoryOrder("Others", 3)]
[DisplayName("Traffic")]
[Description("Traffic at a point")]
[ReadOnly(true)]
[PropertyOrder(1)]

[Category("Special")]
[CategoryOrder("Special", 2)]
[DisplayName("Special cases")]
[Description("Contains the special cases and files")]
[PropertyOrder(1)]

Here's a sample on how it should be used:

[CategoryOrder("General", 1)]
[CategoryOrder("Advanced", 2)]
[CategoryOrder("Other", 3)]
public class MyClass
{
    [Category("General")]
    public string Property1 { get; set; }
    [Category("Advanced")]
    public int Property2 { get; set; }
    [Category("Other")]
    public double Property3 { get; set; }
    [Category("General")]
    public string Property4 { get; set; }
    [Category("Advanced")]
    public int Property5 { get; set; }
    [Category("Other")]
    public double Property6 { get; set; }
}

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM