gpt4 book ai didi

c# - Xceed PropertyGrid 中的类别排序

转载 作者:太空宇宙 更新时间:2023-11-03 19:00:34 29 4
gpt4 key购买 nike

我正在使用Xceed 的PropertyGrid 来显示一些元素的特性。元素有不同的类别,例如:常规、高级、其他、特殊。在这里,我发现 Xceed 的属性网格按字母顺序对类别和属性进行排序。我能够使用 [PropertyOrder(n)] 对类别内的属性进行排序。我也想对类别进行排序,所以我尝试使用 CategoryOrder 之类的 [CategoryOrder("General", 0)] 但它显示以下错误:

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

我是不是用错了?下面提供的代码只是展示我如何使用它的示例。

[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)]

最佳答案

这是一个关于如何使用它的示例:

[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; }
}

enter image description here

关于c# - Xceed PropertyGrid 中的类别排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36734712/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com