Thanks to the use of generic collections it is supereasy to bind your favourite object to a datagridview!
First create a new BindingList for the type you want to use as the datasource.
The entire code:
First create a new BindingList for the type you want to use as the datasource.
BindingListNow create a new object of the type BindingSource and set your bindinglist as it's datasourcedata = new BindingList ();
BindingSource dsData = new BindingSource();Now you have the datasource of your DatagridView. Simply assign it to the Datasource project of your DataGridView.
dsData.DataSource = data;
dgvYourDataGridView.DataSource = dsData;The only thing you need to make sure of is that the class you are using has properties. Each property represents a column!
The entire code:
BindingListThat's all for today folks!data = new BindingList ();
BindingSource dsData = new BindingSource();
dsData.DataSource = data;
dgvYourDataGridView.DataSource = dsData;
February 2009

