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

然后,代码将 设置为 myAttributeAttributeCollection 的值BrowsableAttribute,并检查 属性是否可浏览。

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

适用于

另请参阅