0

I am using the command:

selecteddirectory = treeViewDirectory.SelectedNode.Text;

However this always gives the name of the parent node and not the child node selected. How to go about doing this?

4

2 Answers 2

0

You can call the treeview_AfterSelect event to select the child node.

 private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            string selectedNodeText = e.Node.Text;
            MessageBox.Show(selectedNodeText);
        }

Like this:

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

0
selecteddirectory = treeViewDirectory.SelectedNode.Name;

1 Comment

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.