Share via


PropertyGridObject.GetProperties(Attribute[]) Method

Definition

Returns the collection of properties for the property grid, using a specified array of attributes as a filter.

protected:
 virtual System::ComponentModel::PropertyDescriptorCollection ^ GetProperties(cli::array <Attribute ^> ^ attributes);
protected virtual System.ComponentModel.PropertyDescriptorCollection GetProperties (Attribute[] attributes);
abstract member GetProperties : Attribute[] -> System.ComponentModel.PropertyDescriptorCollection
override this.GetProperties : Attribute[] -> System.ComponentModel.PropertyDescriptorCollection
Protected Overridable Function GetProperties (attributes As Attribute()) As PropertyDescriptorCollection

Parameters

attributes
Attribute[]

An array of Attribute objects with which to filter the collection.

Returns

A PropertyDescriptorCollection object that contains the properties that match the specified attributes for the specified component.

Implements

Examples

The following example uses the GetProperties method to get the property collection for the property grid.

protected override PropertyDescriptorCollection
    GetProperties(Attribute[] attributes) {

    PropertyDescriptorCollection PDC =
        base.GetProperties(attributes);
    ArrayList properties = new ArrayList();
    Type thisType = GetType();

    foreach (PropertyDescriptor pd in PDC) {

        AttributeCollection attributCol = pd.Attributes;

        // Display Name Attribute (DNA)
        MyDNAttribute dna = (MyDNAttribute)
            (attributCol[typeof(MyDNAttribute)]);

        if (dna != null) {
            DisplayNameAttribute newDNA =
                GetDisplayNameAttribute(
                dna.Description,
                String.Empty
                );

            properties.Add(
                TypeDescriptor.CreateProperty(
                thisType, pd, newDNA
                ));
        } else {
            properties.Add(pd);
        }
    }

    PDC = new PropertyDescriptorCollection((PropertyDescriptor[])
        properties.ToArray(typeof(PropertyDescriptor)));

    return PDC;
}

Remarks

You can override this method to modify the properties of the System.ComponentModel.PropertyDescriptorCollection object before the properties are shown in the property grid.

Applies to