ListView Sorting with groups enabled

Arokh

Centurion
Joined
Apr 11, 2006
Messages
124
Hi
after quiet some time I finally found the problem why my ListView control isn't sorted despite the sorting:

As soon as I add groups to the listview and assign them to the listviewitems (which are added after the groups are added),
the ListView doesn't respect the insert method, it behaves as if I would use add instead.
Immediately after setting
lstvw_HistoryEps.ShowGroups = False
the order of the listviewitems is correct.

Does somebody know whats going on here?
 
Are you calling BeginUpdate and EndUpdate when updating the Items collection? Not doing so has caused me some very curious problems in the past.
 
Adding didn't solve the problem.

I didn't notice that there was a ListViewItemSorter element in the ListView available,
so I've written my own sorting code, with which it doesn't work (as described above).

If I use ListViewItemSorter to sort it works as it should.

Although both ways should work, I'm going with the ListViewItemSorter since it means less code to write for me.

Although it still interests me why it doesn't work my (old) way.

EDIT

OK it does work, but going with the ListViewItemSorter it is much slower than doing the sorting myself.

So if you/anyone has another idea why it doesn't work...
 
Last edited:
Back
Top