共用方式為


BrowsableAttribute.Browsable 屬性

定義

取得值,表示物件是否為可瀏覽。

public:
 property bool Browsable { bool get(); };
public bool Browsable { get; }
member this.Browsable : bool
Public ReadOnly Property Browsable As Boolean

屬性值

如果物件是可瀏覽則為 true,否則為 false

範例

下列範例會檢查是否 MyProperty 可流覽。 首先,程式代碼會依下列方式取得 的屬性 MyProperty

然後程式代碼會將 設定myAttribute為中的 AttributeCollectionBrowsableAttribute,並檢查 屬性是否可流覽。

// Gets the attributes for the property.
AttributeCollection^ attributes = TypeDescriptor::GetProperties( this )[ "MyProperty" ]->Attributes;

// Checks to see if the property is browsable.
BrowsableAttribute^ myAttribute = dynamic_cast<BrowsableAttribute^>(attributes[ BrowsableAttribute::typeid ]);
if ( myAttribute->Browsable )
{
   // Insert code here.
}
// Gets the attributes for the property.
 AttributeCollection attributes = 
    TypeDescriptor.GetProperties(this)["MyProperty"].Attributes;
 
 // Checks to see if the property is browsable.
 BrowsableAttribute myAttribute = (BrowsableAttribute)attributes[typeof(BrowsableAttribute)];
 if(myAttribute.Browsable) {
    // Insert code here.
 }
' Gets the attributes for the property.
Dim attributes As AttributeCollection = TypeDescriptor.GetProperties(Me)("MyProperty").Attributes

' Checks to see if the property is browsable.
Dim myAttribute As BrowsableAttribute = CType(attributes(GetType(BrowsableAttribute)), BrowsableAttribute)
If myAttribute.Browsable Then
    ' Insert code here.
End If

適用於

另請參閱