我们什么时候需要使用[Browsable(true)]? [英] When do we need to use [Browsable(true)]?
问题描述
何时需要使用 [Browsable(true)]
?
编辑(由SLaks撰写):他在问(我想)为什么人们需要传递 true
作为参数,因为它已经是 true
EDIT (by SLaks): He's asking (I assume) why one would need to pass true
as the parameter, given that it's already true
by default.
推荐答案
MSDN说全部:
应该在属性窗口中显示属性还是事件。
Specifies whether a property or event should be displayed in a Properties window.
例如,如果要创建用户控件,则可能想要用 [Browsable(false)]
装饰与UI无关的属性,以使它们无法通过属性窗口使用。
For example, if you're creating a User Control, you might want to decorate non-UI-related properties with [Browsable(false)]
so that they will not be available through a "Properties" window.
此外,它控制对象的哪些属性可以在 属性yGrid
。
Additionally, it controls which properties of an object can be seen in a PropertyGrid
.
关于我们为什么可以显式传递 true
的原因,我认为这是由于 PropertyGrid
的> BrowsableAttributes 属性。您可以将其设置为包含 BrowsableAttribute 。否
,以便属性网格将显示所有不可浏览的成员。
As for why we can pass true
explicitly, I believe this is due to BrowsableAttributes
property of a PropertyGrid
. You can set it to contain BrowsableAttribute.No
, so that the property grid will display all non-browsable members.
这篇关于我们什么时候需要使用[Browsable(true)]?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!