Xceed PropertyGrid 中的类别排序 [英] Category Ordering In Xceed PropertyGrid
问题描述
我正在使用Xceed 的PropertyGrid 来显示某些元素的特性.元素有不同的类别,例如:General、Advanced、Others、Special.在这里,我发现 Xceed 的属性网格按字母顺序对类别和属性进行排序.我能够使用 [PropertyOrder(n)]
对类别内的属性进行排序.我也想对类别进行排序,所以我尝试使用 CategoryOrder
像 [CategoryOrder("General", 0)]
但它显示以下错误:
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:
错误 2 属性CategoryOrder"在此声明类型上无效.它仅对类"声明有效.
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; }
}
这篇关于Xceed PropertyGrid 中的类别排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!