【问题标题】:Set a UserControl Property to Not Show Up in VS Properties Window将 UserControl 属性设置为不显示在 VS 属性窗口中
【发布时间】:2010-09-09 10:39:12
【问题描述】:

我的 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
}

【问题讨论】:

    标签: c# asp.net visual-studio properties attributes


    【解决方案1】:

    使用以下属性...

    using System.ComponentModel;
    
    [Browsable(false)]
    public bool SampleProperty { get; set; }
    

    在 VB.net 中,这个will be

    <System.ComponentModel.Browsable(False)>
    

    【讨论】:

      【解决方案2】:

      Tons of attributes 用于控制 PropertyGrid 的工作方式。

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

      【讨论】:

        【解决方案3】:

        使用System.ComponentModel.Browsable 属性来

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

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

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2019-05-13
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多