通殺N級目錄樹,只需據實更改第一句 目錄樹 代碼即可.
Dim Lbs As String() ={"产品","客户","雇员","折扣","日期"} '目錄樹級數
完善一下代碼:
Dim Lbs As String() ={"产品","客户","雇员","折扣","日期"} '目錄樹級數
Dim trv As WinForm.TreeView = e.Sender
Dim nd,nd1 As WinForm.TreeNode
Dim flt,s1 As String
Dim n1,Inum As Integer
nd = trv.SelectedNode
For Each nd1 In nd.allNodes '同步子节点选中状态
nd1.Checked = nd.Checked
Next
If nd.ParentNode IsNot Nothing Then '确定父节点选中状态:
For n1 = nd.ParentNode.level To 0 Step -1 '
Inum = nd.ParentNode.Nodes.Count '利用muhua老师的
For Each nd1 In nd.ParentNode.Nodes
Inum+ = Val(nd1.Checked)
Next
nd.ParentNode.Checked = (Inum = 0)
nd = nd.ParentNode
Next
End If
For Each nd In trv.AllNodes
If nd.Level > 0 AndAlso nd.ParentNode.Checked Then '如果父节点选中
Continue For '跳过此节点,处理下一结点
End If
If nd.Checked Then
n1=0
For Each s1 In nd.FullPath.split("\")
flt+ =iif(n1 =0,") Or (" ," and ") & Lbs(n1) & " = '" & s1 & "'"
n1+=1
Next
End If
Next
If flt IsNot Nothing Then
e.Form.Controls("TextBox1").value = flt.Substring(4) & ")"
Tables("订单").Filter = flt.Substring(4) & ")"
End If
此主题相关图片如下:12.gif
以下内容只有回复后才可以浏览
[此贴子已经被作者于2013-6-20 7:44:01编辑过]