Dim trv1 As WinForm.TreeView = Forms("XX").Controls("TreeView1")
Dim dt As DataTable = DataTables("AA")
dim txt as string = "ABCD"
Dim lstnd As new list(of WinForm.TreeNode) '需要保留的节点
For Each nd As WinForm.TreeNode In trv1.AllNodes
Dim y As String = nd.FullPath & " " & py.GetPY(nd.FullPath,True,3)
Dim yn As Boolean = False
If Instr(y,txt) = 0 Then
yn = True
End If
If yn = False Then '''形成保留集合
lstnd.add(nd)
End If
Next
For Each nd As WinForm.TreeNode In trv1.AllNodes
if lstnd.contains(nd) = false then
trv1.nodes.remove(nd)
end if
Next
为什么执行的结果整个树全清了?
[此贴子已经被作者于2021/1/17 16:43:36编辑过]