I'm writing code to eventually pull data from a remote database into a DataGridView using a databinding. I am currently creating the code to work with a CSV file and a BindingList as a test.
I want a display on my form that shows the last time the database was updated. I'm currently using the ListChanged event on my BindingList to update the "last database update" display.
The ListChanged event seems to only be firing if it's hooked up after the database is initially populated. Here's some code from my class that extends DataGridView:
BindingList<CsvTest> Data = new BindingList<CsvTest>;
public void InitGrid()
{
// Data.ListChanged += Data_ListChanged; // Event never fires if this is here!
Data = CsvTest.ParseCsv("test.csv");
Data.ListChanged += Data_ListChanged; // Working when it's here!
this.DataSource = Data; // DataGridView DataSource
}
I would like for my delay to update as the list is initially populated. Can anyone think of any reason why this isn't working?
Thanks a lot.
ParseCsvreturning a newBindingList?, if so that's most likely the reason, try clearing the Binding list and adding the items, the event will most likely work in that scenario. - sa_ddam213