BrowsableAttribute.Browsable 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取一个值,该值指示对象是否可浏览。
public:
property bool Browsable { bool get(); };
public bool Browsable { get; }
member this.Browsable : bool
Public ReadOnly Property Browsable As Boolean
属性值
true 如果对象可浏览,则为否则,为 false.
示例
以下示例检查是否 MyProperty 可浏览。 首先,代码获取以下项的属性 MyProperty :
检索 PropertyDescriptorCollection 对象的所有属性。
索引到要获取
MyProperty的 PropertyDescriptorCollection 。在属性变量中保存此属性的属性。
然后,代码将设置为myAttribute中AttributeCollection值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