BindingRelatedObjectsToDataGridView

When using the EntityFramework4.0 You can bind a DataGridView to related entities (linked entities) by using the DataBindingComplete event. For example (From Lerman, J. "Programming Entity Framework" O'Reilly. pp. 199-200):

   1         private void reservationsDataGridView_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
   2         {
   3             DataGridView gridView = (DataGridView)sender;
   4             foreach (DataGridViewRow row in gridView.Rows)
   5             {
   6                 BAGA.Reservation reservation = (BAGA.Reservation)(row.DataBoundItem);
   7                 BAGA.Trip trip = reservation.Trip;
   8                 row.Cells[tripStartColumn.Index].Value = trip.StartDate.ToShortDateString();
   9                 row.Cells[tripEndColumn.Index].Value = trip.EndDate.ToShortDateString();
  10                 row.Cells[destinationColumn.Index].Value = trip.Destination.DestinationName;
  11             }
  12         }