This article shows you the two-way sorting techniques of the ListView control in the Report view, the source code is as follows
Option expedition
Private sub flow_load ()
Dim i As itemx As ListItemListView1.View = lvwReportWith ListView1.ColumnHeaders.Add IntegerDim,, "number", 600, lvwColumnLeftFor i = 1 To 2.Add,, "content item" & i, 1000, lvwColumnRightNextEnd With
With listview1.listitemsfor i = 1 to 10 set itemx = .add itemx.subitems (1) = i itemx.subitems (2) = chr (64 i) itemx.subitems (3) = format (DateAdd ("M", i, date), "yyyy-mm-dd") Nextend with
End Sub
Private Sub ListView1_ColumnClick (ByVal ColumnHeader As MSComctlLib.ColumnHeader) With ListView1If (ColumnHeader.Index - 1) = .SortKey Then.SortOrder = (.SortOrder 1) Mod 2Else.Sorted = False.SortOrder = 0.SortKey = ColumnHeader.Index - 1.sorted = truend ifend welhend
Finish