Change events

B

Bryan Glennon

I've been mucking around with databinding & I am seeing something I
can't explain...

I have a collection (PersonList) that inherits from CollectionBase and
implements IBindingList. It contains Person objects that implement
IEditableObject.

I have a windows form with three text boxes (last, first & middle name)
and next/prev navigation buttons. There are also two additional buttons
to programmatically change values in the first item in the list (these
are so that I can see what happens when the data is changed outside of
the form.)

The Person object supports LastNameChanged and FirstNameChanged events.
These events are fired from the appropriate property set method.

When I click on the button to programmatically change a single value in
the person at index 0, this is what I see:

FirstName property:set is called
FirstName property:get is called
LastName property:get is called
MiddleName property:get is called

Why are all of the bound values being refreshed in response to a change
in only one?

I see the corresponding behavior when I programmatically change the last
name.

I'm confused.

Any enlightenment will bee appreciated.

Thanks,
Bryan
 
M

Matt Garven

If your BindingManagerBase is a CurrencyManager then it is actually reliant
on the ListChangedEvent rather than the particular <PropertyName>Changed
events.

You will get a CurrencyManager if you're binding to an IBindingList.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top