问题描述
何时需要使用 [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说:
例如,如果要创建用户控件,则可能想要用 [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.
此外,它控制对象的哪些属性可以在。
Additionally, it controls which properties of an object can be seen in a PropertyGrid
.
关于我们为什么可以显式传递 true
的原因,我认为这是由于属性。您可以将其设置为包含,以便属性网格将显示所有不可浏览的成员。
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)]?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!