老师,目录树节点筛选没有作用。
此主题相关图片如下:2024-09-03 12 01 50.jpg
Dim s As String = e.Form.Controls("复选框").Text
Dim Colstr() As String
Dim qts As String() = {"'","#",""}
Dim trv As WinForm.TreeView = e.Sender
Dim flt As String = ""
Dim nd As WinForm.TreeNode
Dim pd As WinForm.TreeNode
Dim notchecked As Integer = 0
Colstr = s.split(",")
For i As Integer = 0 To Colstr.Length - 1
If Tables("水电气数据查询_Table1").Cols.Contains(Colstr(i)) = False Then
If trv.Nodes.Count > 0 Then
trv.Nodes.Clear()
End If
e.Form.Controls("复选框").Text = "选择筛选列(最好包括拼音)"
Return
End If
Next
If e.Node.Name = "显示所有行" Then
If e.Node.Checked = True Then
For Each nd In trv.AllNodes
If nd.Name <> "显示所有行" Then
nd.Checked = False
End If
Next
Tables("水电气数据查询_Table1").Filter = ""
Else
For Each nd In trv.AllNodes
nd.Checked = False
Next
Tables("水电气数据查询_Table1").Filter = (1 = 2)
End If
trv.CollapseAll
Return
Else
trv.AllNodes(0).Checked = False
End If
For Each nd In e.node.allNodes
nd.Checked = False
Next
pd = e.Node.ParentNode
Do While pd IsNot Nothing
pd.Checked = False
pd = pd.ParentNode
Loop
For Each nd In trv.AllNodes
If nd.Checked Then
Dim rts() As String = nd.FullPath.Split("\")
Dim val As String = ""
For i As Integer = 0 To rts.length - 1
If Tables("水电气数据查询_Table1").DataTable.DataCols(Colstr(i)).IsString Then
If rts(i) <> "空" Then
If val > "" Then
val = val & " And "
val = val & Colstr(i) & " = " & qts(0) & rts(i) & qts(0)
Else
val = val & Colstr(i) & " = " & qts(0) & rts(i) & qts(0)
End If
ElseIf rts(i) = "空" Then
If val > "" Then
val = val & " And "
val = val & Colstr(i) & " Is Null"
Else
val = val & Colstr(i) & " Is Null"
End If
End If
ElseIf Tables("水电气数据查询_Table1").DataTable.DataCols(Colstr(i)).IsDate Then
If rts(i) <> #0001-1-1 0:00:00# Then
If val > "" Then
val = val & " And "
val = val & Colstr(i) & " = " & qts(1) & rts(i) & qts(1)
Else
val = val & Colstr(i) & " = " & qts(1) & rts(i) & qts(1)
End If
ElseIf rts(i) = #0001-1-1 0:00:00# Then
If val > "" Then
val = val & " And "
val = val & Colstr(i) & " Is Null"
Else
val = val & Colstr(i) & " Is Null"
End If
End If
ElseIf Tables("水电气数据查询_Table1").DataTable.DataCols(Colstr(i)).IsNumeric Then
If rts(i) <> 0 Then
If val > "" Then
val = val & " And "
val = val & Colstr(i) & " = " & qts(2) & rts(i) & qts(2)
Else
val = val & Colstr(i) & " = " & qts(2) & rts(i) & qts(2)
End If
ElseIf rts(i) = 0 Then
If val > "" Then
val = val & " And "
val = val & Colstr(i) & " Is Null"
Else
val = val & Colstr(i) & " Is Null"
End If
End If
ElseIf Tables("水电气数据查询_Table1").DataTable.DataCols(Colstr(i)).IsBoolean Then
If rts(i) <> False Then
If val > "" Then
val = val & " And "
val = val & Colstr(i) & " = " & qts(0) & True & qts(0)
Else
val = val & Colstr(i) & " = " & qts(0) & True & qts(0)
End If
ElseIf rts(i) = False Then
If val > "" Then
val = val & " And "
val = val & Colstr(i) & " = " & qts(0) & False & qts(0)
Else
val = val & Colstr(i) & " = " & qts(0) & False & qts(0)
End If
End If
End If
Next
If flt > "" Then
flt = flt & " Or (" & val & ")"
Else
flt = val
End If
notchecked + = 1
End If
Next
MsgBox(flt)
If flt > "" AndAlso notchecked > 0 Then
Tables("水电气数据查询_Table1").Filter = flt
Else
Tables("水电气数据查询_Table1").Filter = (1 = 2)
End If