When do we need to use [Browsable(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.
Specifies whether a property or event should be displayed in a Properties window. 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.
Definition. Specifies whether a property or event should be displayed in a Properties window.
As far as I know, never.
I was wrong.
It's necessary if you want to make a property which has [Browsable(false)]
in your base class (such as UserControl.Text
) browsable.
MSDN says it all:
Specifies whether a property or event should be displayed in a Properties window.
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
.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With