Xceed PropertyGrid 中的类别排序
Category Ordering In Xceed PropertyGrid
我正在使用 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; }
}
我正在使用 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; }
}