Dim lvw As WinForm.ListView = e.Form.Controls("ListView1")
lvw.StopRedraw() '暂停绘制
lvw.Rows.Clear() '清除原来的行
lvw.Images.Clear() '清除原来的图片
lvw.View = ViewMode.Tile '显示模式为平铺
lvw.Images.LargeSize = New Size(65, 75) '定义大图标尺寸
lvw.TitleSize = New Size(150, 90) '设置平铺区域的大小
Dim cls() As String = {"楼幢号", "空行1", "户型", "空行2", "主体", "砌体"} '定义列名
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("国家").DataRows '从数据表中提取数据
Dim Key As String = dr("照片")'获取此员工的照片文件
lvw.Images.AddLargeImage(Key, Key) '添加照片,直接用文件名作为图片键值
Dim vr As WinForm.ListViewRow = lvw.Rows.Add() '增加一行
vr.ToolTipText = dr("地块分组") '设置此行的动态提示
vr.ImageKey = Key '设置图片键值
vr.Group = dr("地块分组") '指定所属分组
vr("楼幢号") = dr("楼幢号")
vr("空行1") = " "
vr("户型") = "户型:" & dr("户型")
vr("空行2") = " "
vr("主体") = "主体:" & dr("主体")
vr("砌体") = "砌体:" & dr("砌体")
Next
Dim Filter As String
With e.Form.Controls("地块分组")
If .Value IsNot Nothing Then
Filter = "地块分组 = '" & .Value & "'"
End If
End With
With e.Form.Controls("户型")
If .Value IsNot Nothing Then
Filter = "户型 = '" & .Value & "'"
End If
End With
With e.Form.Controls("主体")
If .Value IsNot Nothing Then
Filter = "主体 = '" & .Value & "'"
End If
End With
If Filter > "" Then
DataTables("国家").loadFilter = Filter
DataTables("国家").load
End If
lvw.ResumeRedraw() '恢复绘制
老师,帮我看看这个代码,要筛选几次才显示正确,是哪里的问题
首先,没看到有筛选的代码。其次什么地方显示不正确?
With e.Form.Controls("地块分组")
If .Value IsNot Nothing Then
Filter = "地块分组 = '" & .Value & "'"
End If
End With
With e.Form.Controls("户型")
If .Value IsNot Nothing Then
Filter = "户型 = '" & .Value & "'"
End If
End With
With e.Form.Controls("主体")
If .Value IsNot Nothing Then
Filter = "主体 = '" & .Value & "'"
End If
End With
If Filter > "" Then
DataTables("国家").loadFilter = Filter
DataTables("国家").load
End If
加入上述筛选代码,要点按钮2次才筛选正确
上面是加载,不是筛选。"国家"这个表数据要2次才能加载出来?
不可能的。
如果说ListView要2次才能显示符号条件的行倒是会,因为先添加ListView数据再加载的数据
Dim Filter As String
With e.Form.Controls("地块分组")
If .Value IsNot Nothing Then
Filter = "地块分组 = '" & .Value & "'"
End If
End With
With e.Form.Controls("户型")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "户型 in ('" & .Value.replace(",", "','") & "')"
MessageBox.Show(Filter)
End If
End With
With e.Form.Controls("主体")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "主体 in ('" & .Value.replace(",", "','") & "')"
MessageBox.Show(Filter)
End If
End With
If Filter > "" Then
DataTables("国家").loadFilter = Filter
DataTables("国家").load
End If
我将代码换成这样,还是一样的,要点2次才出正确的结果