【发布时间】:2015-05-28 16:49:20
【问题描述】:
如果我在包含List<string[]> 或Dictionary<string,string[]>(使用GenericDictionaryEditor)的属性网格中有一个对象,当我单击属性旁边的详细信息并单击添加时,会弹出一条消息说没有构造函数可以找到(对于列表)或找不到无参数构造函数(对于字典)。我真的不懂编辑器或属性网格,如果有任何帮助,我们将不胜感激。
[DataMember(Name="FolderPaths")]
[ReadOnly(false)]
[Description("List of folder paths")]
[Editor(typeof(Wexman.Design.GenericDictionaryEditor<string, string[]>), typeof(UITypeEditor))]
[Wexman.Design.GenericDictionaryEditor(Title="Folder Paths")]
public Dictionary<string, string[]> FolderPaths { get; set; }
这个说没有为 System.string[] 找到构造函数。
[DataMember(Name="FolderPaths")]
[ReadOnly(false)]
[Description("List of folder paths")]
public List<string[]> FolderPaths { get; set; }
【问题讨论】:
-
为什么你有一个用于路径的字符串数组列表?看起来简单的
List<string>会起作用。文件夹路径是否有多个路径或其他东西?我假设您收到错误的原因是因为string[]没有像string[] x = new string[]()这样的构造函数... -
这也是我的猜测。是的,一个路径会有多个路径。
-
可能必须创建一个自定义类型,例如
FolderPath类型,它可以具有默认构造函数,然后使用 get/set 访问器设置路径。
标签: c# arrays propertygrid