ZeroEffect Posted August 4, 2006 Posted August 4, 2006 (edited) I have been through the forum and I have seen many examples of listview sorting but In this one instance I can't get it to work. I am loading a Listview from dbf file if the item found in the db meet the criteria it is added to the listview. No problem I get a full listview of items I wanted. Now the first column is time in the 24 hour format. So I want to sort the column accending, (00:00:00 ==> 24:59:59) I have a class for the listview Item comparer that looks like this. Public Class ListViewItemComparer Implements IComparer Private col As Integer Public Sub New() col = 0 End Sub Public Sub New(ByVal column As Integer) col = column End Sub Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer _ Implements IComparer.Compare On Error Resume Next Return [string].Compare(CType(x, ListViewItem).SubItems(col).Text, CType(y, ListViewItem).SubItems(col).Text) End Function End Class and is called like this lv.ListViewItemSorter = New ListViewItemComparer(1) lv.Sort() but I still get a couple of entries out of wack. The first column will look like this. 00:00:00 01:00:00 12:00:00 20:00:00 17:00:00 23:00:00 This will stay this way even if I call the sort after the Listview is done being loaded. Also If I add a new item to the db it'll be placed at the bottom and not sorted. I have stepped through the code but nothing sticks out. Any thoughts? Thanks ZeroEffect Edited August 4, 2006 by ZeroEffect Quote If you can't find it, Build It. There is no place Like 127.0.0.1 also don't forget 1 + 1 = 10
ZeroEffect Posted August 4, 2006 Author Posted August 4, 2006 Found it I am a Jack A#$. It helps if you sort the right column. I also removed the On error line and changed it to a try catch end try. All is good. Thanks ZeroEffect Quote If you can't find it, Build It. There is no place Like 127.0.0.1 also don't forget 1 + 1 = 10
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.