Dim s As String
Dim l As WinForm.CheckedListBox = e.Form.Controls("CheckedListBox1")
For Each Index As Integer In l.CheckedIndices
s = s & "," & l.Items(Index)
Next
s = s.trim(",")
Dim cs As String = s
Dim idx As String = ""
Dim lst As new List(of String)
Dim flag As Boolean
Dim drs As List(Of DataRow) = DataTables(Vars("btname")).Select("第一列 is not null", cs)
Dim pdr As DataRow = drs(0)
Dim dr As DataRow
For i As Integer = 1 To drs.count - 1
dr = drs(i)
flag = False
For Each c As String In cs.split(",")
If pdr(c) <> dr(c) Then 改为If pdr(c)= dr(c) Then 则直接没有数据显示了 貌似条件数据不符合一样
flag = True
Exit For
End If
Next
If flag = False Then
If lst.Contains(pdr("_Identify")) = False
lst.add( pdr("_Identify") )
End If
lst.add( dr("_Identify") )
End If
pdr = dr
Next
If lst.count > 0 Then
idx = String.Join(",",lst.ToArray)
Tables(Vars("btname")).filter = "第一列 is not null and _Identify not in (" & idx.trim(",") & ") "
Else
MessageBox.Show("没有重复数据!")
End If
单行多列筛选相同的值 代码如下:运行也得到不同部分的数据,怎么修整呢?
Dim s As String
Dim l As WinForm.CheckedListBox = e.Form.Controls("CheckedListBox1")
For Each Index As Integer In l.CheckedIndices
s = s & "," & l.Items(Index)
Next
s = s.trim(",")
Dim cs As String = s
Dim filter As String = "1=2"
Dim ss() As String = s.split(",")
Dim s1 As String = ss(0)
For i As Integer = 1 To ss.length - 1
filter = filter & " or " & s1 & " = " & ss(i)
Next
MessageBox.Show(filter)
Tables(Vars("btname")).filter = filter
运行效果:
此主题相关图片如下:1.png