I have encountered a tricky little problem that's got me a bit stumped.
I have a Listview which has two columns, the first containing a name, and the second containing a number.
I've written the _ColumnClick so that the Name column uses the standard ListView sorting, while clicking on the Number column uses my own custom sort routing (so that numbers are sorted 1, 5, 10 and not 1, 10, 5).
This works fine... almost.
Everything looks fine on the screen, scrolling up and down the listview shows me exactly what i expect.
HOWEVER, if you click on an item when the list is sorted by Number, the ITEM parameter passed to the _ItemClick event is NOT the item that was clicked in the listview.
After investigation, this is because the custom sort (invoked with SendMessage LVM_SORTITEMS) does not re-order the listitems collection.
I need to be able to access the correct Item in the _ItemClick event. As far as I can see this means either:
1) Re-order the listitems collection
2) Ignore the item passed to the event and work out for myself which one was clicked & retrieve it using the API
Note that it's not enough to be able to retrieve the text items (.text and .subitems()) data. I need to be able to access the correct listitem object.
Any help and/or suggestions are most welcome.
There is a simple example which illustrates this problem at http://www.mvps.org/vbnet/index.html?code/callback/lvsortcallback.htm