在VS属性窗口中将UserControl属性设置为不显示

Yaa*_*lis 6 c# asp.net attributes properties visual-studio

我的Asp.net项目中有一个UserControl,它有一个公共属性.当用户在IDE中突出显示UserControl的实例时,我不希望此属性显示在Visual Studio属性窗口中.我应该使用什么属性(或其他方法)来防止它出现?

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

  // other stuff
}
Run Code Online (Sandbox Code Playgroud)

Phi*_*ght 11

使用以下属性...

using System.ComponentModel;

[Browsable(false)]
public bool SampleProperty { get; set; }
Run Code Online (Sandbox Code Playgroud)

在VB.net中,这将是:

<System.ComponentModel.Browsable(False)>
Run Code Online (Sandbox Code Playgroud)