BrowsableAttribute.Browsable Eigenschaft
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Ruft einen Wert ab, der angibt, ob ein Objekt browsebar ist.
public:
property bool Browsable { bool get(); };
public bool Browsable { get; }
member this.Browsable : bool
Public ReadOnly Property Browsable As Boolean
Eigenschaftswert
true
, wenn das Objekt browsebar ist, andernfalls false
.
Beispiele
Im folgenden Beispiel wird überprüft, ob MyProperty
sie durchsucht werden kann. Zunächst ruft der Code die Attribute für MyProperty
ab:
Ruft ein PropertyDescriptorCollection mit allen Eigenschaften für das -Objekt ab.
Indizieren in der PropertyDescriptorCollection , um abzurufen
MyProperty
.Speichern der Attribute für diese Eigenschaft in der Attribute-Variablen.
Dann legt myAttribute
der Code auf den Wert von BrowsableAttribute in AttributeCollection fest, und überprüft, ob die Eigenschaft durchsucht werden kann.
// 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
Gilt für:
Weitere Informationen
Feedback
Feedback senden und anzeigen für