Why ApplySorting causes BindingSource_ListChanged's ListChangedEventArgs to return null

Why ApplySorting causes BindingSource_ListChanged's ListChangedEventArgs to return null

Old forum URL: forums.lhotka.net/forums/t/2654.aspx


GeorgeG posted on Tuesday, April 03, 2007

I have an EditableRootListBase that is attached to a binding source.
If the BindingSource.DataSource
 is attched to the BusinessBase directly
 or
 attched to SortedBindingList object with no ApplySort
ListChangedEventArgs behaves correctly.
private void BindingSource_ListChanged( object sender, ListChangedEventArgs e ) {
   if (e.PropertyDescriptor != null) {
        MessageBox.Show( e.PropertyDescriptor.DisplayName );
    }
}
However, as soon as ApplySort is called either by code or by clicking the grid header
ListChangedEventArgs returns null which is not correct.

Anybody had the same problem and how was being resolved?

Brian Criswell replied on Tuesday, April 03, 2007

Check which type of event was raised, if it was a Reset (which it should be) that does not use the PropertyDescriptor because it is telling listening objects that too much has changed and they should just reread the entire list.  I think PropertyDescriptor is only used for ItemChanged (sometimes) and the Add and Remove descriptor types.

ajj3085 replied on Wednesday, April 04, 2007

Is the actual event arguments parameter coming into the handler as null?

GeorgeG replied on Wednesday, April 04, 2007

Yes, the actual event arguments parameter coming into the handler is  null and should not be.


 

ajj3085 replied on Wednesday, April 04, 2007

Hmm... I'm not sure what code would be causing that.  Have you tried working your way up the call stack to see what class / method is raising the event without event args?

GeorgeG replied on Wednesday, April 04, 2007

You are right. One method did not pass the event args as parameter.

Rocky,
do you think we should update the framework or we will break something?

In the SortedBindingList class
 method SourceChanged()
 added e.PropertyDescriptor to constructor under ListChangedType.ItemChanged

case ListChangedType.ItemChanged:

// an item changed - just relay the event with

// a translated index value

OnListChanged(

new ListChangedEventArgs(

ListChangedType.ItemChanged, SortedIndex( e.NewIndex ), e.PropertyDescriptor ) );//added e.PropertyDescriptor

break;

RockfordLhotka replied on Tuesday, May 01, 2007

I've added this in 3.0 - to both SortedBindingList and FilteredBindingList.

GeorgeG replied on Tuesday, May 01, 2007


Thanks




"RockfordLhotka" <cslanet@lhotka.net>
05/01/2007 01:36 PM
Please respond to
cslanet@lhotka.net

To
"ggeorgiou@jefexservices.com" <ggeorgiou@jefexservices.com>
cc
Subject
Re: [CSLA .NET] Rocky question - Fixed - Re: Why ApplySorting causes BindingSource_ListChanged's ListChangedEventArgs to return null





I've added this in 3.0 - to both SortedBindingList and FilteredBindingList.





Jefferies Execution Services reviews and archives incoming and outgoing e-mail. Archived information may be produced at the request of regulatory authorities or in connection with civil litigation. Copying, disclosure, or distribution of material in this e-mail without prior approval is strictly prohibited. Indications of interest to buy, sell, or cancel will not be considered orders by Jefferies Execution Services until and unless acknowledged as such.

Copyright (c) Marimer LLC