Yolgezer
Yolgezer

Reputation: 41

Get selected tree node item full path in C# (WinForms)

I have a TreeView component and content of it like this:

MainLine  
  + SubLine1 
  + SUbline2
  + Subline3
  + Subline4
  + Subline5
  - Subline6
      SublineDetail1
      **SublineDetail2**
      SublineDetail3

Assume that SublineDetail2 is selected and I want to get full path of it as string to a textbox just like this "(1.6.2)".

How can I do that?

Upvotes: 2

Views: 13467

Answers (1)

user3244607
user3244607

Reputation: 81

private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
{
    TreeNode CurrentNode= e.Node;
    string fullpath= CurrentNode.FullPath;
    MessageBox.Show(fullpath);
}

Upvotes: 8

Related Questions