BrowsableAttribute.Browsable Tulajdonság
Definíció
Fontos
Egyes információk olyan, kiadás előtti termékekre vonatkoznak, amelyek a kiadásig még jelentősen módosulhatnak. A Microsoft nem vállal kifejezett vagy törvényi garanciát az itt megjelenő információért.
Beolvas egy értéket, amely jelzi, hogy egy objektum böngészhető-e.
public:
property bool Browsable { bool get(); };
public bool Browsable { get; }
member this.Browsable : bool
Public ReadOnly Property Browsable As Boolean
Tulajdonság értéke
trueha az objektum böngészhető; egyéb esetben. false
Példák
Az alábbi példa ellenőrzi, hogy böngészhető-e MyProperty . Először a kód a következő attribútumokat MyProperty kapja meg:
PropertyDescriptorCollection Az objektum összes tulajdonságát tartalmazó lekérdezés.
Indexelés a PropertyDescriptorCollection lekéréshez
MyProperty.A tulajdonság attribútumainak mentése az attribútum változóban.
Ezután a kód a benne lévő myAttribute értékre BrowsableAttribute állítjaAttributeCollection, és ellenőrzi, hogy a tulajdonság böngészhető-e.
// 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