views:

175

answers:

1

I have a List of customers that I'm trying to bind to a DataGridView. I have two data classes that looks like:

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 Customer. My problem is the Address Column is only one column and shows "Address" in the column. What's the best way to display columns for all members of Address class in the DataGridView.

+2  A: 

My problem is the Address Column is only one column and shows "Address" in the column.

I think you wanted to say "in the title column".

You could assemble a sentence with StreetAddress and City and show that in each field for the Address column in the grid.

eKek0
WooHoo! Thanks! I just did an override on ToString in AddressDetail to concat address, and it works perfectly!
Aaron Sanders