Databound control problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have created a windows forms control that exposes a DataSource, DisplayMemeber and ValueMember. Everything works fine, but here is my problem: when I drag and drop a DataSet + DataAdapter and use the Fill to fill the dataset, I cannot find a way to notify my control that the data has changed. I have a "RefreshItems" method that parses the datasource and fills the control with the correct data, I also save the CurrencyManager and subscribe to the ItemChanged and MetaDataChanged events. Whatever I do, if I set the datasource before filling the dataset the items do not refresh

1)
oleAdapter1.Fill(this.dataSet1)
dataControl.DataSource = this.dataSet1.Customers

2
dataControl.DataSource = this.dataSet1.Customers
oleAdapter1.Fill(this.dataSet1)

In case 1) all works fine. In case 2) my control doesn't update because I cannot find any event that should be raised in order for me to know that the data was filled in... Should i try to cast the datasource to either DataTable, DataView or DataSet (depending on what the data is) and listen to some events of each specific type?

Any idea how can i catch that

Thank you!
iulian
 
I solved this myself. You must cast the currencyManager to an IBindingList and if the result is not null, then subscribe to the IBindingList.List.ListChange event. In the handler check if the change type is "Reset" which means the list was radically changed and then refresh the items. Works perfectly...
 
Back
Top