如何在属性网格中编辑文件名集合?
我在 C# 类中有一个文件名集合:
private List<string> m_files
public List<string> Files
{
get
{
return m_files;
}
set
{
m_files = value;
}
}
我希望能够在属性网格中显示和编辑此集合,特别是我希望能够使用标准 FileDialog
。哪种方法最简单?
I have a collection of filenames in a C# class:
private List<string> m_files
public List<string> Files
{
get
{
return m_files;
}
set
{
m_files = value;
}
}
I want to be able to display and edit this collection in a property grid, specifically I would like to be able to add files to this collection with a standard FileDialog
. Which is the easiest way to accomplish this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
EditorAttribute
来指定使用CollectionEditor< 编辑此属性/代码>
:
Use the
EditorAttribute
to specify that this property is edited with aCollectionEditor
:您可以劫持 StringCollectionEditor 以获得廉价的解决方案:
但实际上检查文件或使用 OFD 将需要您编写自己的 UITypeEditor。请记住,设计时文件的路径绝不代表您部署项目时它们将具有的路径。
You could hijack the StringCollectionEditor for a cheap solution:
But actually checking the files or using an OFD is going to require you writing your own UITypeEditor. Do keep in mind that the paths of the files at design time is in no way representative for the paths they'll have when you deploy your project.