SortedBindingList - Always adding at end rather than at sorted position

SortedBindingList - Always adding at end rather than at sorted position

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


Blarm posted on Friday, November 09, 2007

I have a SortedBindingList created from a BusinessListBase class.

The Sort used the property DLLine, Ascending

When I add to the BusinessListBase, then item is added at the end of the SortedBindingList which I can see by debugging a for loop over the SortedBindingList. The item has a DLLine value that is less than the first item in the sort and in this case should be placed at the beginning.

If I do an ApplySort straight after I add the item then its is placed in the correct place.

This doesn't seem right to me as I would expect the SortedBindingList to remain sorted.

Bill

mr_lasseter replied on Friday, November 09, 2007

This is the designed behavior.  Just like if you are adding a new file or folder in Windows explorer, the item is added at the end of the list not in the sorted order.  This provides the user with standard windows behavoir.  Just think if the user added an item to a list of 100 items but only the last 10 where displayed, if the item would end up being first in the sorted list the user would not be able to see the item added and wonder if the item was ever added.  If this is the behavior you desire you can certainly call applysort any time the list changes.

Copyright (c) Marimer LLC