本文介绍了如何获得fullpath treeview selectednode索引?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 在Explorer Prog中。 Treeview喜欢这个: First Drive:\ 文件夹A 子文件夹A 子文件夹B 子文件夹C 文件夹B 子文件夹A1 SubFolder A2 子文件夹A3 文件夹C 子文件夹AA 子文件夹BB SubFolder CC SubFolder DD 文件夹D SubFolder AB SubFolder BC SubFolder CD 子文件夹 子文件夹EF 指数: First Drive指数是(0) 文件夹A index是(0) SubFolder A1索引是(0) SubFolder A2索引是(1) SubFolder A3索引是(2) 文件夹B索引是(1) SubFolder A1索引是(0) SubFolder A2索引是(1) SubFolder A3索引是(2) 文件夹C索引是(2) SubFolder AA指数为(0) SubFolder BB指数为(1) SubFolder CC指数为(2) SubFolder DD index是(3) 文件夹D索引是(3) SubFolder AB索引是(0) SubFolder BC索引是(1) SubFolder CD索引是(2) SubFolder DE索引是(3) SubFolder EF索引是(4) 例如 当我选择文件夹C时和Subfolder DD我想获得这样的索引树:(0,2,3)(驱动节点,文件夹节点,子文件节点) 或 当我选择文件夹D和子文件夹EF我希望获得索引树像这样:(0,3,4)(驱动节点,文件夹节点,子文件节点) 我如何获得这些信息? 我的尝试: In an Explorer Prog. Treeview Like this :First Drive:\ Folder A SubFolder A SubFolder B SubFolder C Folder B SubFolder A1 SubFolder A2 SubFolder A3 Folder C SubFolder AA SubFolder BB SubFolder CC SubFolder DD Folder D SubFolder AB SubFolder BC SubFolder CD SubFolder DE SubFolder EFNUMBER OF INDEXES:First Drive index is (0) Folder A index is (0) SubFolder A1 index is (0) SubFolder A2 index is (1) SubFolder A3 index is (2) Folder B index is (1) SubFolder A1 index is (0) SubFolder A2 index is (1) SubFolder A3 index is (2) Folder C index is (2) SubFolder AA index is (0) SubFolder BB index is (1) SubFolder CC index is (2) SubFolder DD index is (3) Folder D index is (3) SubFolder AB index is (0) SubFolder BC index is (1) SubFolder CD index is (2) SubFolder DE index is (3) SubFolder EF index is (4)for excample when I Select Folder C and Subfolder DD I want to get index Tree like this : (0,2,3) (Drive Node, Folder Node, SubFolder Node)ORwhen I Select Folder D and Subfolder EF I want to get index Tree like this : (0,3,4) (Drive Node, Folder Node, SubFolder Node)How can I get this information ?What I have tried:<pre> Private Sub Button10_Click(sender As Object, e As EventArgs) Handles Button10.Click MsgBox(TreeView1.SelectedNode.Parent.Index & "" & TreeView1.SelectedNode.NextNode.Index & "" & TreeView1.SelectedNode.NextNode.Index) End Sub 但不是获取驱动器节点,如果有更多子文件夹则无法获取节点... but not Get Drive Node and can not get the node if there are more Subfolder...推荐答案 怎么样: How about:Private Sub Button10_Click(sender As Object, e As EventArgs) Handles Button10.Click Dim path As New Stack(Of Integer) Dim node As TreeNode = TreeView1.SelectedNode While node IsNot Nothing path.Push(node.Index) node = node.Parent End While Dim nodePath As String = String.Join(",", path) MsgBox(nodePath)End Sub 这篇关于如何获得fullpath treeview selectednode索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-27 01:02