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
Printable View
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
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:
Private Sub TreeView1_AfterSelect(sender As System.Object, e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect Me.Text = e.Node.Name End Sub
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
Presumably the node will still be selected when this is required so something like ....
vb.net Code:
Private Sub ListBox1_DoubleClick(sender As System.Object, e As System.EventArgs) Handles ListBox1.DoubleClick Me.Text = IO.Path.Combine(TreeView1.SelectedNode.Parent.Name, TreeView1.SelectedNode.Name, ListBox1.SelectedItem.ToString) End Sub
?
Need to try it but that looks just what I'm looking for. Thanks so much