Dim mls As String() = {"分类","分类1","种类"} '指定生成目录树的各列
Dim kh As String() = {"'","'","'"} '指定将各列的值括起来的符号,这里都是字符型,所以都是单引号
Dim cs As WinForm.TreeView = e.Sender
Dim sx As String
Dim jd As WinForm.TreeNode
For Each jd In e.node.allNodes '清除子节点的选中标记
jd.Checked = False
Next
jd = e.Node.ParentNode
Do While jd IsNot Nothing '清除父节点的选中标记
jd.Checked = False
jd = jd.ParentNode
Loop
For Each jd In cs.AllNodes
If jd.Checked Then
Dim xjd() As String = jd.FullPath.Split("\")
Dim val As String = ""
For i As Integer = 0 To xjd.length - 1
If val > "" Then
val = val & " And "
End If
val = val & mls(i) & " = " & kh(i) & xjd(i) & kh(i)
Next
If sx > "" Then
sx = sx & " Or (" & val & ")"
Else
sx = val
End If
End If
Next
Tables("供应商").Filter = sx
e.Form.Controls("TreeView1").BuildTree("供应商", "分类|分类1|种类")