Yaakov Ellis
Yaakov Ellis

Reputation: 41500

Set a UserControl Property to Not Show Up in VS Properties Window

I have a UserControl in my Asp.net project that has a public property. I do not want this property to show up in the Visual Studio Property Window when a user highlights an instance of the UserControl in the IDE. What attribute (or other method) should I use to prevent it from showing up?

class MyControl : System.Web.UI.UserControl {
  // Attribute to prevent property from showing in VS Property Window?
  public bool SampleProperty { get; set; }

  // other stuff
}

Upvotes: 6

Views: 9070

Answers (3)

Codeslayer
Codeslayer

Reputation: 3393

Use the System.ComponentModel.Browsable attribute to

> ' VB
> 
>     <System.ComponentModel.Browsable(False)>

or

// C#
    [System.ComponentModel.Browsable(false)]

Upvotes: 2

Phil Wright
Phil Wright

Reputation: 22906

Use the following attribute ...

using System.ComponentModel;

[Browsable(false)]
public bool SampleProperty { get; set; }

In VB.net, this will be:

<System.ComponentModel.Browsable(False)>

Upvotes: 11

user1228
user1228

Reputation:

Tons of attributes out there to control how the PropertyGrid works.

[Browsable(false)]
public bool HiddenProperty {get;set;}

Upvotes: 3

Related Questions