我的目录树结构是:e.Form.Controls("TreeView1").BuildTree("订单", "产品|客户|是否结帐")
以下代码只筛选二个节点的。麻烦帮忙修改一下,能够筛选某一产品,某一客户及是否结帐。Dim trv As WinForm.TreeView = e.Sender
Dim flt As String
For Each nd As WinForm.TreeNode In e.node.Nodes '同步子节点选中状态
nd.Checked = e.Node.Checked
Next
If e.node.ParentNode IsNot Nothing Then '去掉父节点选中状态
e.node.ParentNode.Checked = False
End If
For Each nd As WinForm.TreeNode In trv.AllNodes
If nd.Level > 0 AndAlso nd.ParentNode.Checked Then '如果父节点选中
Continue For '跳过此节点,处理下一结点
End If
If nd.Checked Then
If flt > "" Then
flt = flt & " Or " '注意用or而不是And
End If
If nd.Level = 0 Then '注意下面的条件都要用括号括起来
flt = flt & "( 产品 = '" & nd.Text & "')"
Else
flt = flt & "( 产品 = '" & nd.ParentNode.Text & "' And 客户 = '" & nd.Text & "')"
End If
End If
Next
Tables("订单").Filter = flt
[此贴子已经被作者于2012-12-30 16:37:11编辑过]