Narmatha Balasundaram Narmatha Balasundaram -4 years ago 140
C# Question

When do we need to use [Browsable(true)]?

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.

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download