2

I have a treeview, with multiple nested levels. For e.g., the root node of a Treeview is A, then inside A there is an item B and inside B there is another item C , like A-->B-->C. If for e.g., B is expanded in this treeview, is it possible to get the position of B in the Treeview in the code?

  • What do you mean by position? do you want its parent? – Ghasem Dec 23 '15 at 06:40
  • what I want is, I have two treeview's. Treeview A. and Treeview B. I want to expand two treeview items simultaneously. For e.g., If Treeview A has an item, "Item1" and Treeview B has an item , "Item2". When I expand "Item1", "Item2" should be expanded simultaneously. – Nisarga Nagaraj Dec 26 '15 at 05:53

1 Answers1

1

Edit: for WPF, check this for level and this and this for coordinates.

The object for WPF is TreeViewItem

Note: below was my previous answer referring to WinForm TreeView

What you look for is TreeNode.Level

In your case, TreeNode.Level of A will return 0, B return 1, C return 2.

Community
  • 1
  • 1
Ian
  • 30,182
  • 19
  • 69
  • 107