This documentation is archived and is not being maintained.

BrowsableAttribute.Browsable Property

Gets a value indicating whether an object is browsable.

Namespace: System.ComponentModel
Assembly: System (in system.dll)

public bool Browsable { get; }
/** @property */
public boolean get_Browsable ()

public function get Browsable () : boolean

Not applicable.

Property Value

true if the object is browsable; otherwise, false.

The following example checks to see whether MyProperty is browsable. First the code gets the attributes for MyProperty by:

  • Retrieving a PropertyDescriptorCollection with all the properties for the object.

  • Indexing into the PropertyDescriptorCollection to get MyProperty.

  • Saving the attributes for this property in the attributes variable.

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 = (BrowsableAttribute)attributes[typeof(BrowsableAttribute)];
 if(myAttribute.Browsable) {
    // Insert code here.
 }
 

    // Gets the attributes for the property.
    AttributeCollection attributes = 
        TypeDescriptor.GetProperties(this).get_Item("MyProperty").
        get_Attributes();

    // Checks to see if the property is browsable.
    BrowsableAttribute myAttribute = 
        ((BrowsableAttribute)(attributes.get_Item(
        BrowsableAttribute.class.ToType())));

    if (myAttribute.get_Browsable()) {
        // Insert code here.
    }
} //Method 

// Gets the attributes for the property.
 var attributes : AttributeCollection = 
    TypeDescriptor.GetProperties(this)["MyProperty"].Attributes;
 
 // Checks to see if the property is browsable.
 var myAttribute : BrowsableAttribute = BrowsableAttribute(attributes[BrowsableAttribute]);
 if(myAttribute.Browsable) {
    Console.WriteLine("MyProperty is browsable.");
 }
 

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0
Show: