Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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.

like image 788
Narmatha Balasundaram Avatar asked Mar 25 '10 13:03

Narmatha Balasundaram


People also ask

What is browsable false )]?

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.

What is browsable attribute in C#?

Definition. Specifies whether a property or event should be displayed in a Properties window.


2 Answers

As far as I know, never.

EDIT

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.

like image 177
SLaks Avatar answered Sep 19 '22 16:09

SLaks


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.

like image 39
Anton Gogolev Avatar answered Sep 22 '22 16:09

Anton Gogolev