Hey Jon! Thanks for the response!
Yes there actually is something specific that I woud like to know about
this.
I am using Rockford Lhotka's CSLA framework for .NET in my project. In this
framework, he develops a base collection class that can be derived from by a
business object developer in order to create a strongly-typed collection of
business objects.
In order to allow this class to be bindable using .NET data binding, he
implements the IBindingList interface, which includes a ListChanged event.
Pretty straight-forward stuff. So, in his class he includes the event code
as expected:
public event ListChangedEventHandler ListChanged;
virtual protected void OnListChanged(ListChangedEventArgs e)
{
if(ListChanged != null)
ListChanged(this, e);
}
Because his class is derived from CollectionBase, there are a series of
events in CollectionBase that can be used to raise the ListChanged event.
One of those events is the SetCompete event that I asked about in my
origional post. In order to raise a ListChanged event whenever the base
CollectionBase class raises its SetComplete event, Rocky overrides the
CollectionBase OnSetComplete method as follows:
override protected void OnSetComplete(int index, object oldValue, object
newValue)
{
OnListChanged( new ListChangedEventArgs(ListChangedType.ItemChanged,
Index);
}
This is great because someone using this collection can handle then handle
the ListChanged event, which is exactly what i want to do. I am using a
collection that is derived from Rocky's class asa child collection within a
parent object. I need to know if anything changes on any of the objects in
the child collection so that I can propagate those changes up through the
parent object and reflect them on my form. However, there is a problem...
If you look at the values that are passed to the event handler by the
ListChangedEventArgs object, you will notice that they do not include
oldValue and newValue, even though this information is made available by the
CollectionBase class. I need this information so that I can compare the two
objects to determine exactly what has changed between them. I can't do that
with nothing but an index.
But as I studied the ListChangedEventArgs type, I noticed that it does not
have fields for holding the oldValue and newValue values. I am not sure why
it was desinged this way. Why would a type designed to hold infomation
about a list changed event not be designed to hold all of the information
about that event??
So, I guess I am wondering how I can overcome this shortcoming. Should I
create my own ListCahnged event and my own ListChangedEventArgs type?
Well.......I hope I explained that clearly, Jon. Its probably a little more
than you were expecting!!!
If you have time to look it over and you have some comments, I would really
appreciate hearing from you. You have always been helpful in the past.
Thanks!
Craig