如题 ListView 可以按某个条件排序么?我试着用红色的部分做,系统提示listview没有相关组件
(在窗口的afterload里加也不可以)
Dim lvw As WinForm.ListView = Forms("分类").Controls("ListView1")
lvw.StopRedraw() '暂停绘制
lvw.Rows.Clear() '清除原来的行
lvw.Images.Clear() '清除原来的图片
lvw.View = ViewMode.Tile '显示模式为平铺
lvw.Images.LargeSize = New Size(130,100) '定义大图标尺寸
lvw.TitleSize = New Size(150,120) '设置平铺区域的大小
Dim cls() As String = {"cs1","cs2","cs3","cn_name"} '定义列名
For i As Integer = 0 To cls.Length - 1 '增加列
Dim c As WinForm.ListViewColumn = lvw.Columns.Add()
c.Name = cls(i) '指定列名
Next
For Each dr As DataRow In DataTables("商品").Select("[lei] is null") '从数据表中提取数据
' Dim Key As String = ProjectPath & "images\aaa\" & dr("ppp")'
Dim Key As String = "e:\as2\" & dr("ppp")'
lvw.Images.AddLargeImage(Key, Key) '添加照片,直接用文件名作为图片键值
Dim vr As WinForm.ListViewRow = lvw.Rows.Add() '增加一行
vr.Sort =dr("costprice")
vr.ToolTipText = dr("cn_name") '设置此行的动态提示
vr.ImageKey = Key '设置图片键值
For Each cl As String In cls '逐列取值
vr(cl) = dr(cl)
Next
vr.tag = dr
Next
lvw.ResumeRedraw() '恢复绘制
[此贴子已经被作者于2017/2/14 19:04:12编辑过]