次の方法で共有


PropertyGridObject.GetProperties(Attribute[]) メソッド

定義

指定した属性の配列をフィルターとして使用して、プロパティ グリッドのプロパティのコレクションを返します。

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

パラメーター

attributes
Attribute[]

コレクションを Attribute フィルター処理するオブジェクトの配列。

戻り値

指定 PropertyDescriptorCollection したコンポーネントの指定した属性に一致するプロパティを格納している オブジェクト。

実装

次の例では、 メソッドを GetProperties 使用して、プロパティ グリッドのプロパティ コレクションを取得します。

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.PropertyDescriptorCollection 変更するには、このメソッドをオーバーライドできます。

適用対象