PropertyGrid:隐藏基类属性,如何?
PropertyGrid...对于用户我只想留下其中的几个。但现在我看到了所有,当用户看到像 Dock 或 Cursor 之类的东西时会感到困惑...... 希望现在已经清楚了...
PropertyGrid... for users Id like to leave only several of them. But now I see all, and users would be confused when see something like Dock or Cursor and such...
Hope it's clear for now...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用此属性:
对于继承的属性:
另一个想法(因为您试图隐藏所有基类成员):
然后对于属性网格:
缺点是它将这些属性的访问级别从 更改
为
Use this attribute:
For the inherited properties:
Another idea (since you are trying to hide all base class members):
and then for your property grid:
The down side is it changes your access level of those properties from
to
要隐藏
MyCtrl
属性,请使用该属性的[Browsable(False)]
属性。要隐藏继承属性,您需要覆盖基础属性并应用可浏览属性。
注意:您可能需要根据具体情况添加
virtual
或new
关键字。更好的方法是使用
ControlDesigner
。设计器有一个名为PreFilterProperties
的覆盖,可用于向PropertyGrid
提取的集合添加额外的属性。您可以将要隐藏的属性名称添加到
propertiesToHide
中,从而实现更清晰的分离。到期信用:http://www.codeproject.com/KB/webforms/HidingProperties。 aspx#
To hide
MyCtrl
properties, use[Browsable(False)]
attribute on the property.To hide inherited proeprties, you need to override the base and apply the browsable attribute.
Note: You may need to add the
virtual
ornew
keyword depending on the circumstances.A better approach would be to use a
ControlDesigner
. The designer has an override calledPreFilterProperties
that can be used to add extra attributes to the collection that has been extracted by thePropertyGrid
.You can add the names of proeprties you wish to hide to
propertiesToHide
which allows for a cleaner separation.Credit where due: http://www.codeproject.com/KB/webforms/HidingProperties.aspx#