實現listview控制元件report檢視下任何列頭的雙向排序 (轉)

amyz發表於2007-11-28
實現listview控制元件report檢視下任何列頭的雙向排序 (轉)[@more@]

本文向大家展示了listview在report檢視下任何列頭的雙向排序技巧,如下:namespace prefix = o ns = "urn:schemas--com::office" />

Option Explicit

Private Sub Form_Load()

Dim i As Integer
Dim itemx As ListItem
ListView1.View = lvwReport
With ListView1.ColumnHeaders
.Add , , "編號", 600, lvwColumnLeft
For i = 1 To 2
.Add , , "內容項" & i, 1000, lvwColumnRight
Next
End With


With ListView1.ListItems
For 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")
Next
End With

End Sub

Private Sub ListView1_ColumnClick(ByVal ColumnHeader As MmctlLib.ColumnHeader)
With ListView1
If (ColumnHeader.Index - 1) = .SortKey Then
.SortOrder = (.SortOrder + 1) Mod 2
Else
.Sorted = False
.SortOrder = 0
.SortKey = ColumnHeader.Index - 1
.Sorted = True
End If
End With
End Sub


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10752019/viewspace-985563/,如需轉載,請註明出處,否則將追究法律責任。

相關文章