winform datagridviewtextboxcolumn datapropertyname child
本文关键字:child datapropertyname datagridviewtextboxcolumn winform | 更新日期: 2023-09-27 18:28:19
I需要在表中显示子实体。
// Entitys
public class Sp
{
public int Id { get; set; }
public int IdDict { get; set; }
public Dict Dict { get; set; }
}
public class Dict
{
public int Id { get; set; }
public string Caption { get; set; }
}
如何绑定?
var c = new DataGridViewTextBoxColumn
{
// How can I do?
DataPropertyName = "Dict.Caption"
}
应用程序显示一个空单元格
已经这样做了。工作
// Entitys
public class Sp
{
public int Id { get; set; }
public int IdDict { get; set; }
public Dict Dicts { get; set; }
public DictCaption { get { return Dicts.Caption; } }
}
public class Dict
{
public int Id { get; set; }
public string Caption { get; set; }
}
....
dataGridView.DataSource = dbContext.Set<Sp>().ToList;
var c = new DataGridViewTextBoxColumn
{
DataPropertyName = "DictCaption"
}