BrowsableAttribute(Boolean) 构造函数

定义

初始化 BrowsableAttribute 类的新实例。

public:
 BrowsableAttribute(bool browsable);
public BrowsableAttribute(bool browsable);
new System.ComponentModel.BrowsableAttribute : bool -> System.ComponentModel.BrowsableAttribute
Public Sub New (browsable As Boolean)

参数

browsable
Boolean

true 如果在设计时可以修改属性或事件,则为否则,为 false. 默认值为 true

示例

以下示例将属性标记为可浏览。 此代码将创建一个新 BrowsableAttribute代码,将其值 BrowsableAttribute.Yes设置为,并将其绑定到属性。

   [Browsable(true)]
   int get()
   {
      // Insert code here.
      return 0;
   }
   void set( int value )
   {
      
      // Insert code here.
   }
}
[Browsable(true)]
public int MyProperty
{
    get =>
        // Insert code here.
        0;
    set
    {
        // Insert code here.
    }
}
<Browsable(True)> _
Public Property MyProperty() As Integer
    Get
        ' Insert code here.
        Return 0
    End Get
    Set
        ' Insert code here.
    End Set
End Property

注解

使用值的BrowsableAttribute构造函数标记属性true时,此属性的值设置为常量成员Yes。 对于用 BrowsableAttributefalse构造函数标记的属性,值为 No。 因此,如果要在代码中检查此属性的值,则必须将属性指定为 BrowsableAttribute.YesBrowsableAttribute.No

适用于

另请参阅