C# 属性网格中的列表扩展器,带有genric ICustomTypeDescriptor
我有一个实现接口的泛型类(C# 属性网格中的列表扩展器,带有genric ICustomTypeDescriptor,c#,list,propertygrid,icustomtypedescriptor,C#,List,Propertygrid,Icustomtypedescriptor,我有一个实现接口的泛型类(Parameters.cs):ICustomTypeDescriptor 我将泛型类用于几个不同的类,其中之一是: private Parameters<Class1> _class1Parameters; public Parameters<Class1> Class1Parameters { get { return _class1Parameters; } set { _class1
Parameters.cs
):ICustomTypeDescriptor
我将泛型类用于几个不同的类,其中之一是:
private Parameters<Class1> _class1Parameters;
public Parameters<Class1> Class1Parameters
{
get { return _class1Parameters; }
set { _class1Parameters= value; }
}
现在,列表显示为Propertygrid(“…”)中的三个点
我想用扩展器(“+”)显示它,我们如何通过ICustomTypeDescriptor
来实现它
编辑:
我尝试将
[TypeConverter(typeof(ExpandableObjectConverter))]
放在Pos
列表上,但没有任何帮助 最后我设法通过了这个网站:
您在属性网格中显示的是什么对象?@lazyberezovsky,位置列表,以及您的泛型
参数
类如何与问题相关?@lazyberezovsky,在泛型参数
中,我实现了接口:ICustomTypeDescriptor
。属性网格使用它:参数
。您刚才说它使用位置列表。这应该不是问题——若您将位置列表指定给属性网格,它将允许在集合编辑器中查看所有位置。另外,您没有指定您使用的是什么-是WinForms吗?
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; }
}