属性网格只显示某些品类品类、只显示、网格、属性

2023-09-03 15:17:41 作者:日落时的沧桑

我有一个PropertyGrid的是一个对象,具有以下属性类别上使用:样式,演算和其它

I got a PropertyGrid that is use on an object that have the following property category : Style, Calcul and Misc

我要的是只显示给用户的演算类,但我不希望使用浏览的属性,因为我希望所有这些属性在Visual Studio中可见。

What I want is to only show to the user the Calcul category, but I don't want to use the browsable attribute because I want all these property to be visible in Visual studio.

所以,我需要的,是一个IN- code解决方案。

So, what I need, is an in-code solution.

我使用。NET 3.5 C#

I use .Net 3.5 c#

推荐答案

的PropertyGrid 有一个属性 - BrowsableAttributes ;这个分配您的类别:

PropertyGrid has a property - BrowsableAttributes; assign this your categories:

        propGrid.BrowsableAttributes = new AttributeCollection(
            new CategoryAttribute("Calcul"));

和(希望),它应该工作。

And (hopefully) it should work.