简体   繁体   English

是否可以在C#中的Designer属性网格中隐藏控件属性?

[英]is it possible to hide control properties in designer property grid in c#?

I was wondering if is it possible to hide or only show specific properties of a control or custom control on the property grid at design time. 我想知道是否有可能在设计时在属性网格上隐藏或仅显示控件或自定义控件的特定属性。

this is what I mean: assume I have a Custom ComboBox 这就是我的意思:假设我有一个自定义组合框

when I'm on the designer view I only would like to see it's DataSource, ValueMember and DisplayMember properties. 在设计器视图上时,我只希望看到它的DataSource,ValueMember和DisplayMember属性。

is this possible? 这可能吗?

There is a BrowsableAttribute that when set to false would hide the property, but since you are deriving from ComboBox, you wouldn't be able to add the attribute since those properties are in the base class. 有一个BrowsableAttribute,当设置为false时将隐藏该属性,但是由于您是从ComboBox派生的,因此您将无法添加该属性,因为这些属性在基类中。 I haven't tried this, so you'll have to, but what might work is if you hide the properties you want to hide by using the new keyword in your custom ComboBox class and applying the Browseable(false) attribute there. 我没有尝试过,所以必须这样做,但是可能的工作是,如果通过在自定义ComboBox类中使用new关键字并在其中应用Browseable(false)属性来隐藏要隐藏的属性。 But you'd have to do that for every property you want to hide. 但是您必须对要隐藏的每个属性执行此操作。 If that doesn't work, then I guess the answer would be no :). 如果那不起作用,那么我想答案将是:)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM