C# 将数组/列表放入DataGridView列

C# 将数组/列表放入DataGridView列,c#,arrays,list,datagridview,C#,Arrays,List,Datagridview,我的代码如下所示: public class A { public string N{ get; set; } public int E1 { get; set; } public int E2{ get; set; } public List<Genre> G{ get; set; } [System.ComponentModel.Browsable(false)] pu

我的代码如下所示:

public class A
    {
        public string N{ get; set; }

        public int E1 { get; set; }

        public int E2{ get; set; }

        public List<Genre> G{ get; set; }

        [System.ComponentModel.Browsable(false)]
        public string L { get; set; }
    }
列表G在一段时间后被设置,并且具有正确的值。 所以我想要的是,有第四个DataGridView列,它向我显示列表的内容,比如“Action,Fatasy,SciFy”等等


我希望您理解我的需要,并提前感谢您的帮助:)

您可以为此创建一个计算属性

public string GDisplay 
{
    get 
    {
        return String.Join(", ", G);
    }
}
然后在网格中使用
GDisplay
表示G。显然,这是一种只读设计。如果您希望能够通过网格修改G的值,则必须为
GDisplay
实现一个setter。例如:

    set 
    {
        G = value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
                 .Select(x => x.Trim())
                 .ToList();   
    }
thx,这工作得很好:)我不需要编辑它,所以没有必要这样做
    set 
    {
        G = value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
                 .Select(x => x.Trim())
                 .ToList();   
    }