在PropertyGrid中编程隐藏属性属性、PropertyGrid

2023-09-06 08:56:13 作者:黒车载一程

我在寻找隐藏取决于用户在下降什么选择/显示性能。我处理事件的罚款,但实际上并不能做出正确的属性消失。我发现上线的解决方案,主要是从2005年和因为我已经有很少的经验,这我想我必须做一些错误的,如果隐藏属性是这样的难。

I'm looking to hide/show properties depending on what selection the user makes in a drop. I am handling the event fine, but cannot actually make the correct properties disappear. The solutions I have found on line are mainly from 2005 and as I've had very little experience with it I thought I must be doing something wrong if hiding properties is this hard.

到目前为止,我已经尝试访问属性,一旦该事件被处理,但只读和IsBrowsable属性是只读的。

So far I have tried accessing the property once the event is handled but the ReadOnly and IsBrowsable properties are read only.

PropertyGrid中有一个属性BrowsableAttributes,它接受一个属性列表,但只能消极,不能做或 - 只和。提供的属性集合;类别 - 测试和isbrowsable - 真实的;返回那些同时匹配并作为我不能提供多个AttributeCollections我不能作出足够具体的隐藏有需要的,而把其他人看到的搜索。

The propertygrid has a property BrowsableAttributes that takes an Attribute list but only works negatively and cannot do or - only and. Providing an attribute collection of ; category - 'test' and isbrowsable - true; returns those that match both and as I can't provide multiple AttributeCollections I cannot make the search specific enough to hide the necessary ones whilst leaving others visible.

我一直在敲打我的头靠在墙上,在过去几个小时想必须有一个更简单的方法。

I have been banging my head against a wall for the past couple of hours thinking there must be an easier way.

推荐答案

您是否尝试过将这种属性的属性:

Have you tried applying this attribute to a property:


[Browsable(false)]
public object SomeProperty{
}

在这样 SomeProperty 将不会出现在PropertyGrid的。

In that way SomeProperty will not appear on the propertygrid.