Results 1 to 5 of 5

Thread: Get Child Node Name

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2013
    Posts
    40

    Get Child Node Name

    Hi,

    Is there any code that can display the name of a child node in say a Message box on an AfterSelect or click event?

    The nodes that i have are basically folder name's and i just need to be able to reference the folder name and not the path.

    Thanks

  2. #2
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Get Child Node Name

    We're assuming this is what? A standard Treeview control? And we're getting the name of the node selected? Or a child of the selected node? Or the termination point of the branch ... or ....?

    Assuming the simplest scenario ...

    vb.net Code:
    1. Private Sub TreeView1_AfterSelect(sender As System.Object, e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
    2.         Me.Text = e.Node.Name
    3.     End Sub
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  3. #3

    Thread Starter
    Member
    Join Date
    Oct 2013
    Posts
    40

    Re: Get Child Node Name

    Sorry 1 Parent Node with multiple child nodes that are folder names within 1 directory.

    I actually have a listbox that, when the child node is selected, a SQL query is executed and some file names appear. The query has a criteria that is part of the file name displayed in the child node.

    Essentially what should be happening is that the file in the listbox, once double clicked, will copy into the folder of the selected Child node.

    The copying of the file I'm all fine with its just I'm struggling to reference the child node from the listbox.

    The reason I asked for it in a message box was simply to see what the syntax may be.

    Thanks
    Last edited by MarkGB; Jan 5th, 2014 at 03:18 AM. Reason: Typo

  4. #4
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Get Child Node Name

    Presumably the node will still be selected when this is required so something like ....

    vb.net Code:
    1. Private Sub ListBox1_DoubleClick(sender As System.Object, e As System.EventArgs) Handles ListBox1.DoubleClick
    2.         Me.Text = IO.Path.Combine(TreeView1.SelectedNode.Parent.Name, TreeView1.SelectedNode.Name, ListBox1.SelectedItem.ToString)
    3.     End Sub

    ?
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  5. #5

    Thread Starter
    Member
    Join Date
    Oct 2013
    Posts
    40

    Re: Get Child Node Name

    Need to try it but that looks just what I'm looking for. Thanks so much

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