Groups | Blog | Home
all groups > dotnet windows forms databinding > october 2006 >

dotnet windows forms databinding : BindingSource and RaiseListChangedEvents


Mark Atkinson
10/27/2006 8:53:03 AM
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
10/28/2006 11:20:43 AM
Hi,

[quoted text, click to view]

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








AddThis Social Bookmark Button