VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



ListView Sort

by Steve Tempest (5 Submissions)
Category: Miscellaneous
Compatability: Visual Basic 3.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (7 Votes)

This Is a handy code for sorting a ListView Box by whichever column header is clicked.

Rate ListView Sort

Private Sub ListView1_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
  ListView1.Sorted = True
  
  If ListView1.SortKey = ColumnHeader.Index - 1 Then
    If ListView1.SortOrder = lvwAscending Then
      ListView1.SortOrder = lvwDescending
    Else
      ListView1.SortOrder = lvwAscending
    End If
    
  Else
    ListView1.SortOrder = lvwAscending
    ListView1.SortKey = ColumnHeader.Index - 1
    
  End If
  
End Sub

Download this snippet    Add to My Saved Code

ListView Sort Comments

No comments have been posted about ListView Sort. Why not be the first to post a comment about ListView Sort.

Post your comment

Subject:
Message:
0/1000 characters