我有一个包含2个类别的PropertyGrid:“Customer Test 1”和“Customer Test 2”
如果我在BrowseableAttributes中只有一个CategoryAttribute,则会显示ONE Category。 如果我在BrowseableAttributes中显示BOTH / TWO CategoryAttribute,则会显示NONE类别。
为什么?
public class Customer
{
[DisplayName("first name...:")]
[Category("Customer Test 1")]
public string FirstName { get; set; }
[DisplayName("number...")]
[Category("Customer Test 1")]
public int Number { get; set; }
[DisplayName("wage...:")]
[Category("Customer Test 2")]
public int Wage { get; set; }
[DisplayName("description...:")]
[Category("Customer Test 1")]
public string Desc { get; set; }
[DisplayName("shit...:")]
[Category("Customer Test 1")]
public string Nonsens { get; set; }
}
public Form1()
{
InitializeComponent();
Attribute[] attributes = new Attribute[]{ new CategoryAttribute("Customer Test 1"), new CategoryAttribute("Customer Test 2") };
propertyGrid1.BrowsableAttributes = new AttributeCollection(attributes);
propertyGrid1.PropertySort = PropertySort.Categorized;
propertyGrid1.ToolbarVisible = true;
propertyGrid1.SelectedObject = new Customer() { FirstName = "Bernd", Number = 100, Desc =
"steine", Wage = 3333, Nonsens = "crap" };
}
答案 0 :(得分:1)
您确定如果为BrowsableAttributes分配多个属性,属性只需要有1个匹配属性而不是所有属性吗?
换句话说,BrowsableAttributes可以作为过滤器使用AND运算符而不是OR。但我不得不承认我自己没试过。