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

[入库:2005年8月18日] [更新:2007年3月25日]

本文简介:选择自 callzjy 的 blog

本文向大家展示了listview控件在report视图下任何列头的双向排序技巧,源代码如下

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

本文关键:callzjy VB 控件
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top