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.
        return 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

注解

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

适用于

另请参阅