简体   繁体   English

Xceed PropertyGrid中的类别排序

[英]Category Ordering In Xceed PropertyGrid

I am using PropertyGrid of Xceed to display characteristics of some elements. 我正在使用Xceed的PropertyGrid显示某些元素的特征。 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. 在这里,我发现Xceed的propertygrid按字母顺序对类别和属性进行排序。 I was able to sort the properties inside the categories by using [PropertyOrder(n)] . 我可以使用[PropertyOrder(n)]对类别内的属性进行排序。 I also wanted to sort the categories so, I tried using CategoryOrder like [CategoryOrder("General", 0)] but it shows the following error: 我也想类别排序所以,我尝试使用CategoryOrder[CategoryOrder("General", 0)] ,但它显示了以下错误:

Error 2 Attribute 'CategoryOrder' is not valid on this declaration type. 错误2属性'CategoryOrder'在此声明类型上无效。 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; }
}

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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