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 取得します。

  • PropertyDescriptorCollectionオブジェクトのすべてのプロパティを含む を取得しています。

  • を取得MyPropertyするための へのPropertyDescriptorCollectionインデックス作成。

  • このプロパティの属性を attributes 変数に保存します。

次に、コードは 内AttributeCollectionの のBrowsableAttribute値に設定myAttributeし、プロパティが参照可能かどうかを確認します。

// 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

適用対象

こちらもご覧ください