Compartir a través de


PropertyGridObject.GetProperties(Attribute[]) Método

Definición

Devuelve la colección de propiedades de la cuadrícula de propiedades, utilizando una matriz especificada de atributos como filtro.

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

Parámetros

attributes
Attribute[]

Matriz de Attribute objetos con los que se va a filtrar la colección.

Devoluciones

Objeto PropertyDescriptorCollection que contiene las propiedades que coinciden con los atributos especificados para el componente especificado.

Implementaciones

Ejemplos

En el ejemplo siguiente se usa el GetProperties método para obtener la colección de propiedades de la cuadrícula de propiedades.

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;
}

Comentarios

Puede invalidar este método para modificar las propiedades del System.ComponentModel.PropertyDescriptorCollection objeto antes de que las propiedades se muestren en la cuadrícula de propiedades.

Se aplica a