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。 對於以 BrowsableAttribute 建構子 false標記為 的性質,其值為 No。 因此,當你想檢查程式碼中這個屬性的值時,必須指定為 BrowsableAttribute.YesBrowsableAttribute.No

適用於

另請參閱