locked
IList<T> in PropertiesWindow display Count ? RRS feed

  • Question

  • I developed VSPackage and want to display object in Properties window, everything works fine except for IList<T> list data type. Other class type not a collection works as expected, except this data show Count property only, even I already put TypeConverterAttribute on this class.  It seems Visual Studio ignore my converter.

    Here is the example :

    If I show AList in VSPackage selection track, it will show this object in Properties window with Count property only, and that is not what I expected.

    BUT if I show B type which have property return AList type, this property will use AListTypeConverter and show data as expected.

    The question is why when I want to show any class inherited from IList<T> or ICollection<T> , Properties window does not read TypeConverterAttribute ?

    class AListTypeConverter : TypeConverter
    {
         public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
            {
                  //.... return my - PropertyDescriptorCollection
            }
    }
    [TypeConverte(typeof(AListTypeConverter))]
    class AList : IList<A> {}
    
    class B
    {
         AList AList {get; set;}
    
    }


    It's hard to be advanced programmer

    Thursday, January 24, 2013 2:34 AM

Answers

  • I think in this case, the property grid is using the TypeDescriptor class methods directly, instead of going through TypeConverter which seems to be used only for properties. So, you would need to derive AList from an ICustomTypeDescriptor instead and implement GetProperties(Attribute[] attributes) (mostly).


    Simon Mourier

    • Marked as answer by IRW7 Friday, January 25, 2013 12:10 PM
    Thursday, January 24, 2013 8:09 AM

All replies

  • I think in this case, the property grid is using the TypeDescriptor class methods directly, instead of going through TypeConverter which seems to be used only for properties. So, you would need to derive AList from an ICustomTypeDescriptor instead and implement GetProperties(Attribute[] attributes) (mostly).


    Simon Mourier

    • Marked as answer by IRW7 Friday, January 25, 2013 12:10 PM
    Thursday, January 24, 2013 8:09 AM
  • yeah you are right, I already implemented the thing.

    Thanks for the answer.


    It's hard to be advanced programmer

    Friday, January 25, 2013 12:10 PM