I have the following classes:
public class MyItems : List<MyItem>
{
...
}
public class MyItem
{
...
}
I've instantiated MyItems and assigned it to the DataSource property of a WinForms datagrid.
Everything displays properly, but when I try to add rows, nothing happens. What I do is case the grids DataSource back to MyItems, add an instance of MyItems to it, and then set the DataSource back to the list. I can step through the code and see that the count of items in the datasource is growing, but the grid isn't displaying them. Any ideas?
//Form Load
MyItems lstItems = new MyItems();
lstItems.Add(new MyItem("1"));
lstItems.Add(new MyItem("2"));
//Grid displays two rows;
grd.DataSource = lstItems;
//Add button click event
MyItems lstItmes = (MyItems)grd.DataSource;
lstItems.Add(new MyItem("3"));
//Grid does not display new row
grd.DataSource = lstItems;