让我们想象一下我有以下课程
public class Master
{
public string MasterName = "Something";
public List<Detail> details = new List<Detail>();
}
public class Detail
{
public string Foo = "Test";
}
然后我想在 DataGridView 中显示 Details 对象的集合,使用下面的代码
DataGridViewTextBoxColumn column = new DataGridViewTextBoxColumn();
column.DataPropertyName = "Details.Foo";
column.HeaderText = "Foo header";
dgv.Columns.Add(column);
该列显示在网格中,但没有值