实现listview控件report视图下任何列头的双向排序 (转)

实现listview控件report视图下任何列头的双向排序 (转)[@more@]

本文向大家展示了listview控件在report视图下任何列头的双向排序技巧,源代码如下XML:namespace prefix = o ns = "urn:schemas-microsoft-com:Office: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 MSCOmctlLib.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/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/10752019/viewspace-985563/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值