To make the list view sort its items when the user clicks on a column header, use this code in the ListView_ColumnClick event.
With ListView1 '// change to the name of the list view
Static iLast As Integer, iCur As Integer
.Sorted = True
iCur = ColumnHeader.Index - 1
If iCur = iLast Then .SortOrder = IIf(.SortOrder = 1, 0,
1)
.SortKey = iCur
iLast = iCur
End With
Simple!
Comments