问题描述举例:我目录树AfterCheckNode事件;点击层级为:001.003进行筛选;筛选结果确包含了001.001.003;001.003.001;001.003的数据。我希望只筛选001.003.001和00.1.003而不能筛选出001.001.003;代码如下,需如何优化:
Dim trv As WinForm.TreeView = e.Sender
Dim flt As String
Dim nd As WinForm.TreeNode
For Each nd In e.node.allNodes '清除子节点的选中标记
nd.Checked = False
Next
nd = e.Node.ParentNode
Do While nd IsNot Nothing '清除父节点的选中标记
nd.Checked = False
nd = nd.ParentNode
Loop
For Each nd In trv.AllNodes
If nd.Checked Then
Dim val = "层级 Like '%" & nd.FullName.replace("\", ".") & "%'"
If flt > "" Then
flt = flt & " Or (" & val & ")"
Else
flt = val
End If
End If
Next
Tables("用户信息").Filter = flt