Compartir a través de


PropertyGridObject.GetDisplayNameAttribute(String, String) Método

Definición

Obtiene el atributo de nombre para mostrar de un método property, event o public void que no toma ningún argumento.

protected:
 System::ComponentModel::DisplayNameAttribute ^ GetDisplayNameAttribute(System::String ^ friendlyName, System::String ^ configPropertyName);
protected System.ComponentModel.DisplayNameAttribute GetDisplayNameAttribute (string friendlyName, string configPropertyName);
member this.GetDisplayNameAttribute : string * string -> System.ComponentModel.DisplayNameAttribute
Protected Function GetDisplayNameAttribute (friendlyName As String, configPropertyName As String) As DisplayNameAttribute

Parámetros

friendlyName
String

La descripción de la propiedad.

configPropertyName
String

Nombre de configuración de la propiedad.

Devoluciones

Objeto DisplayNameAttribute para un método de propiedad, evento o void público que no toma ningún argumento.

Ejemplos

En el ejemplo siguiente se usa el GetDisplayNameAttribute método para proporcionar información sobre el objeto que realiza la llamada.

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.DisplayNameAttribute objeto antes de que las propiedades se muestren en la cuadrícula de propiedades.

Se aplica a