Dave

Dave

  • NA
  • 161
  • 0

DataGridView source an IList

Nov 18 2008 9:15 PM

Hi there,

I am trying to set the DataSource of a DataGridView to an IList object. The code is as follows:

private void lstBooks_SelectedIndexChanged(object sender, EventArgs e)

{

ListBox theListBox = null;

DataRowView bookView = null;

DataRow book = null;

System.Collections.IList lendings = null;

int count = 0;

// Get the selected DataRow from Books

theListBox = sender as ListBox;

bookView = theListBox.SelectedItem as DataRowView;

book = bookView.Row;

// Get all the rows from Lendings using the DataRelation created in BuildRelationship()

lendings = book.GetChildRows(library.Relations["BookHistory"]);

// Clear the DataGridView and re-populate it with the rows from Lendings for that book

dgvLendHistory.DataSource = null;

dgvLendHistory.DataSource = lendings;

 }

This has not worked. As you can see from the following screenshot, the IList object is not empty, whereas the DataGridView is: http://i167.photobucket.com/albums/u122/sixesallround/toolTip.png

Also, some new columns have been added to the DataGridView:

http://i167.photobucket.com/albums/u122/sixesallround/newColumns.png

None of those columns depicted in that image were created by me as part of the DataGridView.

Any assistance would be greatly apprecited.

Cheers