Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi All, I use List View Control

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
Hi All,

I use List View Control and I want to make the listing go acsending or descending when clicked on the tab. How go about? Ideas welcome to this Ideasfactory!


Thanks in advance
 
Use this type of thing...

Private Sub ListView1_ColumnClick(ByVal ColumnHeader As ColumnHeader)
' When a ColumnHeader object is clicked, the ListView control is
' sorted by the subitems of that column.
' Set the SortKey to the Index of the ColumnHeader - 1
ListView1.SortKey = ColumnHeader.Index - 1
' Set Sorted to True to sort the list.
ListView1.Sorted = True
End Sub



 
This'll set to Ascending or Descending. I can't take full credit, though - I used I snippet I found and played with it.

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

I think there's an FAQ on here as well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top