I am using a class called SimpleFilteredList which I got from this site:
http://blogs.msdn.com/b/winformsue/archive/2007/12/06/filtering-code.aspx
It allows me to apply basic sorting to business objects when added to a DataGridView through a BindgingSource. It has served my purposes very well, however I don't understand one aspect.
Each time a new row is selected in the DataGridView this prompts the overridden EndNew function in the SimpleFilteredList class to be called. This is particularly annoying when the last row was the previous row selected because it forces the sorting algorithm to be executed.
All the columns and the DataGridView have Readonly set to True, and AllowUserToAddRows and AllowUserToDeleteRows are set to False.
How can I stop this EndNew function being called when a new row is selected in the DataGridView?
EndNew function in SimpleFilteredList Class:
public override void EndNew(int itemIndex)
{
// Check to see if the item is added to the end of the list,
// and if so, re-sort the list.
if (sortPropertyValue != null && itemIndex > 0 && itemIndex == this.Count - 1)
ApplySortCore(this.sortPropertyValue, this.sortDirectionValue);
base.EndNew(itemIndex);
}