在这里,我在Treeview下面有如图所示的视图。
对于子节点,G g
我想从下到上获取所有父节点的名称并存储到列表中。列表中的装置应加G g,F f,D d,B b。
请提出解决方案。
提前致谢...
我为它创建了一个函数,该函数将添加列表中的所有父对象,直到对于所选节点而言,父对象不是空。
Public Function AllParents() As List(of String)
Dim listOfNodeHierarchy As New List(Of String)
listOfNodeHierarchy.Add(node.ToString)
'If Child Node has parent, add the parent name of the Child node to the list
While (node.Parent IsNot Nothing)
listOfNodeHierarchy.Add(node.Parent)
node = node.Parent
End While
return listOfNodeHierarchy
End Function
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句