此主题相关图片如下:12.png
点击查询按钮,表格中的数据会根据条件刷新,但listview的显示的数据不会变,如果需要跟着一起变,要怎么处理。
Dim Filter As String
With e.Form.Controls("comboBox1")
If .Value IsNot Nothing Then
Filter = "温区 = '" & .Value & "'"
End If
End With
With e.Form.Controls("TextBox1")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "条码 = '" & .Value & "'"
End If
End With
With e.Form.Controls("TextBox2")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "商品名称 = '" & .Value & "'"
End If
End With
If Filter > "" Then
Tables("商品基础信息").Filter = Filter
End If
'-------------------------------------------------------------------
Dim lvw As WinForm.ListView = e.Form.Controls("ListView1")
lvw.View = ViewMode.Details
lvw.Reset()
lvw.RetrieveAll()
lvw.GridLines=True
Dim cls() As String = {"编码","条码","商品名称","箱规","放码数","温区","保质期天数","毛重","外径长","外径宽","外径高","备注"} '定义列名
Dim wds() As String = {60,120,300,60,60,120,60,60,60,60,60,100} '定义列宽
For i As Integer = 0 To cls.Length - 1 '增加列
Dim c As WinForm.ListViewColumn = lvw.Columns.Add()
c.Text = cls(i) '指定列标题
c.Name = cls(i) '指定列名
c.Width = wds(i) '指定列宽
Next
For Each dr As DataRow In DataTables("商品基础信息").DataRows '从数据表中提取数据
Dim vr As WinForm.ListViewRow = lvw.Rows.Add() '增加一行
For Each cl As String In cls '逐列取值
vr(cl) = dr(cl)
Next
vr.Tag= dr
Next
数据表中只有1行,但liestview中会所有的显示出来,不过双击listview中的记录,未在数据表中的那条记录无任何反应。
[此贴子已经被作者于2020/5/3 20:24:19编辑过]