Binding DataGridView from List Task

I have a list of clients that I am trying to bind to a DataGridView. I have two data classes that look like this:

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; }
}

      

Then when I try to populate the DataGridView I use:

CustomerInfo custInfo = new CustomerInfo();
CustomerGrid.DataSource = custInfo.GetCustomers();

      

GetCustomers will return a list of customers. My problem is that the address column is only one column and it shows "Address" in the column. What is the best way to display columns for all members of the Address class in the DataGridView.

+1


a source to share


1 answer


My problem is the Address column only has one column and it shows "Address" per column.

I think you meant "in the header column".



You can collect the proposal using StreetAddress and City and show what is in each field for the Address column in the grid.

+2


a source







All Articles