C# DataGridView从列表绑定问题
我有一个试图绑定到DataGridView的客户列表。我有两个数据类,看起来像:C# DataGridView从列表绑定问题,c#,.net,datagridview,C#,.net,Datagridview,我有一个试图绑定到DataGridView的客户列表。我有两个数据类,看起来像: public class Customer { public string Name { get; set; } public AddressDetail Address { get; set; } } public class AddressDetail { public string StreetAddress { get; set; } public string C
public class Customer
{
public string Name { get; set; }
public AddressDetail Address { get; set; }
}
public class AddressDetail
{
public string StreetAddress { get; set; }
public string City { get; set; }
}
然后,当我尝试填充DataGridView时,我使用:
CustomerInfo custInfo = new CustomerInfo();
CustomerGrid.DataSource = custInfo.GetCustomers();
GetCustomers将返回一个客户列表。我的问题是地址列只有一列,并且在列中显示“地址”。在DataGridView中为Address类的所有成员显示列的最佳方式是什么
我的问题是地址栏不正确
只有一列,在中显示“地址”
专栏
我想你想说“在标题栏”
您可以用StreetAddress和City组合一个句子,并在网格中地址列的每个字段中显示它们。WooHoo!谢谢我刚刚在ToString in AddressDetail上对concat address做了一个覆盖,它工作得非常好!