生成目录树的代码
Dim tr As WinForm.TreeView = e.Form.Controls("TreeView1")
Dim nd As WinForm.TreeNode
Dim dt As DataTable = DataTables("minfor")
tr.StopRedraw()
tr.Nodes.Clear
'tr.Nodes.Add("全部")
For Each dr As DataRow In dt.datarows
If dr.IsNull("parentid") Then
nd = tr.Nodes.Add(dr("mid"),dr("mname"))
Functions.Execute("AddChildren1",nd,dt)
End If
Next
tr.ResumeRedraw()
点击目录树筛选代码:
Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
Dim ids As String
Dim nd As WinForm.TreeNode
Dim pd As WinForm.TreeNode
Dim key As String = e.Node.Name
If key = "全部" Then
Tables("mframe").Filter = ""
Else
For Each nd In e.node.allNodes '清除子节点的选中标记
nd.Checked = False
Next
pd = e.Node.ParentNode
Do While pd IsNot Nothing '清除父节点的选中标记
pd.Checked = False
pd = pd.ParentNode
Loop
For Each nd In trv.AllNodes
pd = nd
Do While pd IsNot Nothing
If pd.Checked Then
If ids > "" Then
ids= ids & ","
End If
ids = ids & "'" & nd.name & "'"
Exit Do
Else
pd = pd.ParentNode
End If
Loop
Next
If ids > "" Then
Tables("mframe").Filter = "mid In (" & ids & ")"
End If
End If