BrowsableAttribute.Browsable Eigenschaft

Definition

Ruft einen Wert ab, der angibt, ob ein Objekt durchbrochen werden kann.

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

Eigenschaftswert

truewenn das Objekt durchbrochen werden kann; andernfalls . false

Beispiele

Im folgenden Beispiel wird überprüft, ob MyProperty sie durchbrochen werden können. Zuerst ruft der Code die Attribute für MyProperty Folgendes ab:

Anschließend legt myAttribute der Code den Wert des Ins BrowsableAttribute fest AttributeCollection und überprüft, ob die Eigenschaft durchbrochen 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