Advertisement
7_2009-2012 Miscellaneous #217807

Sorting by columnheaders in listviews

This allows a user to sort the contents of a listview by clicking on a column header in report-mode. Clicking again will sort descending.

AI

AI 요약: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

소스 코드
original-source
Dim iCol As Integer
Private Sub ListView1_ColumnClick(ByVal ColumnHeader As_ MSComctlLib.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
  
  If ColumnHeader.Index - 1 <> iCol Then
    ListView1.SortOrder = 0
  Else
    ListView1.SortOrder = Abs(ListView1.SortOrder - 1)
  End If
  
  ListView1.SortKey = ColumnHeader.Index - 1
  
  ' Set Sorted to True to sort the list.
  
  ListView1.Sorted = True
  iCol = ColumnHeader.Index - 1
End Sub
Upload
원본 댓글 (3)
Wayback Machine에서 복구됨