在属性网格中列出扩展器,使用通用ICustomTypeDescriptor

时间:2013-04-09 06:59:00

标签: c# list propertygrid icustomtypedescriptor

我有一个实现接口的泛型类(Parameters.cs):ICustomTypeDescriptor

我将泛型类用于几个不同的类,其中一个是:

    private Parameters<Class1> _class1Parameters;

    public Parameters<Class1> Class1Parameters
    {
        get { return _class1Parameters; }
        set { _class1Parameters= value; }
    }

Class1.cs:

public class Class1
{
    private List<Position> _pos = new List<Position>();

    public List<Position> Pos
    {
        get { return _pos ; }
        set { _pos = value; }
    }  

    //Other variables
}

职位等级:

public class Position
{
    public string Name { get; set; }
    public double Position { get; set; }
}

现在,列表在Propertygrid(“...”)中显示三个点。

我希望它与Expander(“+”)一起显示,我们如何通过ICustomTypeDescriptor进行显示?

修改

我尝试将[TypeConverter(typeof(ExpandableObjectConverter))]放在Pos列表上,但没有帮助。

1 个答案:

答案 0 :(得分:1)

最后,我设法通过这个网站:

<强> Customized display of collection data in a PropertyGrid

相关问题