I'm trying to wrap my head around how BindingList works in a dummy project. The eventual goal is [Microsoft.VisualBasic.PowerPacks.DataRepeater]->[BindingList of POCOs that are backed by Dapper/SQL Server Compact and automagically do CRUD on ListChanged] (as opposed to [DataRepeater]->[DataTable]; please DO leave feedback on validity of this approach in the comments).
My rationale for Add()'ing records in the dummycollection constructor was that it should SELECT existing records from the db at the time of its birth.
The specific question of the moment is: Why does Add()'ing behave differently on the inside versus the outside? My expectation is that the ListChanged event should fire in both cases, but it doesn't. I'm sure I'm missing something simple.
Outside:
private void Form1_Shown(object sender, EventArgs e)
{
dummies = new dummycollection();
dummyBindingSource.DataSource = dummies;
dummies.Add(new dummy() { dummyid=0, dummytext="outside" }); //outside, gets message
}
Inside:
class dummycollection : BindingList<dummy>
{
public dummycollection() // ctor
{
ListChanged += HandleChange;
Items.Add(new dummy() { dummyid=0, dummytext="ctor0" }); //inside, no message
}
private void HandleChange(object sender, ListChangedEventArgs e)
{
System.Diagnostics.Debug.Print(e.ListChangedType.ToString());
}
}
Furthermore, the "insider" record behaves strangely compared to the "outsider" record. When I put a DataGridView on my form for troubleshooting, and edit dummytext in the repeater and grid, visible updates between the two are sporadic or unpredictable when clicking around the various controls. The "outsider" record visibly updates more consistently.