|
-
Jul 8th, 2004, 03:05 PM
#1
Thread Starter
Junior Member
Listview ColumnClick SortOrder
This code sorts listview text columns but does not sort numeric columns properly. I appreciate any suggestions!
Code:
With ListView2
.SortKey = ColumnHeader.Index - 1
.Sorted = True
If .SortOrder = lvwAscending Then
.SortOrder = lvwDescending
Else
.SortOrder = lvwAscending
End If
.SortKey = ColumnHeader.Index - 1
End With
-
Jul 8th, 2004, 03:34 PM
#2
listview is limited in that it only sorts on text and not on numeric... what I have done in some instances is format the number padding with 0s to the largest amount the field could be.. so if it could be a 5 digit number then i would load it to the list as
Format$(MyNum,"00000")
this will cause the sort to work, but depending on what you are doing, the 0s may be a pain in the arse. they are certainly ugly to look at....
same thing for dates... i started loading dates into listview as yyyy-mm-dd because that will always sort correctly versus the more traditional mm/dd/yyy style used here in the US.
If you goto MS website and search the KB, there is an article about sorting values via code, but I remember it was a lot of code. and using some shifty stuff to get it to work right...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|