次の方法で共有


PropertyGridObject.GetDisplayNameAttribute(String, String) メソッド

定義

引数を受け取っていないプロパティ、イベント、またはパブリック void メソッドの表示名属性を取得します。

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

パラメーター

friendlyName
String

プロパティの説明。

configPropertyName
String

プロパティの構成名。

戻り値

DisplayNameAttribute引数を受け取っていないプロパティ、イベント、またはパブリック void メソッドの オブジェクト。

次の例では、 メソッドを GetDisplayNameAttribute 使用して、呼び出し元オブジェクトに関する情報を提供します。

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

注釈

プロパティがプロパティ グリッドに表示される前に、オブジェクトのプロパティを System.ComponentModel.DisplayNameAttribute 変更するには、このメソッドをオーバーライドできます。

適用対象