digitaldrew
Well-known member
- Joined
- Nov 10, 2012
- Messages
- 167
- Programming Experience
- Beginner
Hello Everyone..I hope someone can help me out a little here. I'm currently loading some information into a ListView box and I'm trying to sort the items by the date shown - but it doesn't appear to be working.
This is how the ListView normally looks
I've gone in and added the following code into my ListView1_ColumnClick
Now this does seam to arrange them, but not exactly how I'd like. If you look at the screenshot below you'll see how the code above arranges the items..
As you see by looking at the screenshot above, it has arranged the items but it looks like it arranged them by the first set of numbers, not the actual date. How would I arrange these so the item with the oldest date would actually show up first?
This is how the ListView normally looks

I've gone in and added the following code into my ListView1_ColumnClick
VB.NET:
Private Sub ListView1_ColumnClick(ByVal sender As Object, ByVal e As System.Windows.Forms.ColumnClickEventArgs) Handles ListView1.ColumnClick
' Determine if the clicked column is already the column that is
' being sorted.
If (e.Column = ListView1Sorter.SortColumn) Then
' Reverse the current sort direction for this column.
If (ListView1Sorter.Order = SortOrder.Ascending) Then
ListView1Sorter.Order = SortOrder.Descending
Else
ListView1Sorter.Order = SortOrder.Ascending
End If
Else
' Set the column number that is to be sorted; default to ascending.
ListView1Sorter.SortColumn = e.Column
ListView1Sorter.Order = SortOrder.Ascending
End If
' Perform the sort with these new sort options.
ListView1.Sort()
End Sub
Now this does seam to arrange them, but not exactly how I'd like. If you look at the screenshot below you'll see how the code above arranges the items..

As you see by looking at the screenshot above, it has arranged the items but it looks like it arranged them by the first set of numbers, not the actual date. How would I arrange these so the item with the oldest date would actually show up first?