I'm trying to bind my winform controls to a BindingSource instead of a
DataView and I'm setting the DataView as the BindingSource's DataSource
property.
My main reason for binding to the Bindingsource instead of the DataView
directly is to take advantage of the RaiseListChangedEvents boolean property
in the BindingSource.
Then I have code that (in summary) looks like this:
// start of code
bindingSource.RaiseListChangedEvents = false;
// do stuff like merging data into underlying dataset
// set filters on dataviews, etc
bindingSource.RaiseListChangedEvents = true;
bindingSource.ResetBindings (false);
// end of code
When I'm "doing stuff" to the underlying data, I'm noticing that ListChange
events are still firing. I have hooked up the ListChange events of the
DataViews that are the DataSource of the BindingSource objects earlier but I
would have thought that they'd be supressed. Is it only the BindingSource's
own ListChange that gets affected and not the underlying DataSource (in this
case a DataView)?
Bart Mermuys - 28 Oct 2006 12:20 GMT
Hi,
> I'm trying to bind my winform controls to a BindingSource instead of a
> DataView and I'm setting the DataView as the BindingSource's DataSource
[quoted text clipped - 24 lines]
> this
> case a DataView)?
Well, no it won't suppress the DataView ListChanged events.
- The CurrencyManager is still the list-manager, it provides the changed
events, current item and item property info for any Controls that are bound
to a list including those that are bound to a BindingSource.
- The BindingSource however owns a CurrencyManager so the Controls will use
that one. (BindingSource is ICurrencyManagerProvider)
- The BindingSource also wraps the DataSource and 'sits' between the
DataSource and the CurrencyManager. (BindingSource is IBindingList)
Since the BindingSource is in between, it can suppress the changed events
going from the DataSource to the CurrencyManager and Controls use the
CurrencyManager.
HTH,
Greetings