BrowsableAttribute.Browsable Vlastnost
Definice
Získá hodnotu, která označuje, zda je objekt Procházet.Gets a value indicating whether an object is browsable.
public:
property bool Browsable { bool get(); };
public bool Browsable { get; }
member this.Browsable : bool
Public ReadOnly Property Browsable As Boolean
Hodnota vlastnosti
true
Pokud je objekt Procházet; v opačném případě false
.true
if the object is browsable; otherwise, false
.
Příklady
V následujícím příkladu jsou zkontrolovány, zda lze MyProperty
Procházet.The following example checks to see whether MyProperty
is browsable. Nejprve kód získá atributy pro MyProperty
:First the code gets the attributes for MyProperty
by:
Načítání a PropertyDescriptorCollection se všemi vlastnostmi objektu.Retrieving a PropertyDescriptorCollection with all the properties for the object.
Indexování do PropertyDescriptorCollection pro Get
MyProperty
.Indexing into the PropertyDescriptorCollection to getMyProperty
.Ukládání atributů pro tuto vlastnost v proměnné atributů.Saving the attributes for this property in the attributes variable.
Pak kód nastaví myAttribute
na hodnotu BrowsableAttribute v AttributeCollection a zkontroluje, zda je vlastnost procházet.Then the code sets myAttribute
to the value of the BrowsableAttribute in the AttributeCollection and checks whether the property is browsable.
// 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