Results 1 to 4 of 4

Thread: How can I get fullpath treeview selectednode index ?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2018
    Posts
    77

    How can I get fullpath treeview selectednode index ?

    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 EF

    NUMBER 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)
    OR

    when 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 ?


    Code:
     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...

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: How can I get fullpath treeview selectednode index ?

    A tree is an inherently recursive structure so traversing a TreeView should pretty much always be done using recursion. There are many, many examples around of that sort of thing so you should research that.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Nov 2018
    Posts
    77

    Re: How can I get fullpath treeview selectednode index ?

    Quote Originally Posted by jmcilhinney View Post
    A tree is an inherently recursive structure so traversing a TreeView should pretty much always be done using recursion. There are many, many examples around of that sort of thing so you should research that.
    all example are are only about to get Exact SelectedNode index. Not FulPATH index as I mean to say.

    if I missed can u help me ? (I reseached more then hundreds links but I cant find as I said)

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: How can I get fullpath treeview selectednode index ?

    They are EXAMPLES> That's the point. They exemplify a principle and you then implement the same principle in your specific scenario. Examples are not intended to be turnkey solutions to a problem. You are supposed to apply your mind to them and understand what they are doing so you can then use that knowledge yourself else where.

    If you have a node, you can easily get that node's parent and then the index of that node in its parent's child node collection. You can then do the same for the parent and its parent and so on, recursing up the tree until you get to the root. If you do that for each node in the chain then you will have the indexes for the entire path. Done.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width