c# - 如何在属性网格中编辑文件名集合?

标签 c# collections propertygrid

我在 C# 类中有一组文件名:

    private List<string> m_files

    public List<string> Files
    {
        get
        {
            return m_files;
        }
        set
        {
            m_files = value;
        }
    }

我希望能够在属性网格中显示和编辑该集合,特别是我希望能够使用标准的 FileDialog 将文件添加到该集合。哪种方法最简单?

最佳答案

使用 EditorAttribute指定使用 CollectionEditor 编辑此属性:

private List<string> m_files

[EditorAttribute(typeof(System.ComponentModel.Design.CollectionEditor), typeof(System.Drawing.Design.UITypeEditor))]
public List<string> Files
{
    get
    {
        return m_files;
    }
    set
    {
        m_files = value;
    }
}

关于c# - 如何在属性网格中编辑文件名集合?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4134194/

相关文章:

c# - 如何关联客户和付款详细信息

C#:.exe 中的 File.Delete() 问题

python - 有没有更简单的方法来按长度过滤掉计数器键? Python

java - 检索 ArrayListMultimap 键

php - Eloquent 嵌套关系与 where 子句查询在错误条件下返回集合

.net - 使用 PropertyGrid 设置 PerformanceCounter

c# - PropertyGrid UITypeEditor 禁用单元格编辑

c# - 从 session 将连接字符串分配给表适配器

c# - FtpWebRequest FTP 下载与 ProgressBar

c# - 如何获取 PropertyGrid 的单元格值 (c#)?