Dim Lbs As String() ={"年份","月份","字母","Name","编号"} \'通用多选目录树加载代码.套用时只需修改本行.
Dim trv As WinForm.TreeView = e.form.Controls("TreeView1")
Dim nd As WinForm.TreeNode = trv.SelectedNode
\'If e.sender.Nodes("所有记录").checked Then
\'e.sender.Nodes("所有记录").checked = False
\'End If
If e.node.text = "所有节点" Then
msgbox(123)
Else
e.sender.Nodes("所有节点").checked = False
\'本来代码
Dim flt,s1 As String
Dim n1 As Integer
For Each ndx As WinForm.TreeNode In nd.allNodes \'同步子节点选中状态
ndx.Checked = nd.Checked
Next
If nd.ParentNode IsNot Nothing Then \'确定父节点选中状态:
For i As Integer = nd.ParentNode.level To 0 Step -1 \'
Dim Inum As Integer = nd.ParentNode.Nodes.Count
For Each ndc As WinForm.TreeNode In nd.ParentNode.Nodes
If ndc.Checked Then
Inum = Inum -1
End If
Next
If Inum = 0 Then
nd.ParentNode.Checked = True
nd = nd.ParentNode
Else
nd.ParentNode.Checked = False
nd = nd.ParentNode
End If
Next
End If
For Each nd In trv.AllNodes
If nd.Level > 0 AndAlso nd.ParentNode.Checked Then \'如果父节点选中
Continue For \'跳过此节点,处理下一结点
End If
If nd.name = "所有记录" AndAlso nd.Checked Then \'如果父节点选中
\'nd.Checked = False
Continue For \'跳过此节点,处理下一结点
End If
If nd.Checked AndAlso nd.FullName IsNot Nothing Then
n1=0
For Each s1 In nd.FullName.split("\\")
flt+ =iif(n1 =0,") Or (" ," And ") & Lbs(n1) & " = \'" & s1 & "\'"
n1+=1
Next
End If
Next
Application.DoEvents \'先勾选目录树,再加载数据.
If flt IsNot Nothing Then
Tables("全表").DataTable.LoadFilter = "(" & flt.Substring(4) & ")) and 代码 = \'YGKQ\'"
Tables("全表").DataTable.Load()
\'Tables("全表").Sort = "一级导航排序"
Else
Tables("全表").DataTable.LoadFilter ="[_Identify] Is Null"
Tables("全表").DataTable.Load()
End If
End If