LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Selection of main parent item in hierarchical structure of tree control

I am facing some issue with the selection method of tree control, 
In tree control I had added data in three categories - Main parent, sub parent, child only. Now I want that when I select main parent, all the items in tree control should be selected. If i select the sub parent only item inside it should be selected and if child then only child should be selected.

The problem I am facing is that, when I select the Main parent item, only that item is selecting.
with sub parent item things are working fine till now.
but with child items when I want to select the child then only single child not been selected, all the child under that child been got selected, I am not able to select a single child.

Below I am attaching my image

abhi12_2-1732864544903.png

 

abhi12_1-1732864307166.png

 

  if there any part you want to know please let me know
and please tell the solution if understand the problem.

0 Kudos
Message 1 of 3
(132 Views)

Some comments:

 

  1. It's harder to tell when you're only attaching an image of your code and not the actual VI, but one obvious issue is that you have a race condition where you're setting the symbol inside and outside the loop in parallel and you can't control which item you're actually working on.
  2. I haven't analyzed your code, but I expect you want the symbol of the parent to apply to all the children, so you only want to calculate the new symbol once and use that for all of the relevant items.
  3. I would prefer having the actual data stored in a different data structure which would represent the tree and work on that to make my decisions, but if you're doing it like this, I wouldn't recommend what you're doing, because I expect it might break with collapsed items, multiple child nodes, etc. One thing you can try is to take your starting item and iterate over the following items until you find an item which has an indent level which is equal to or smaller than the original item. That should tell you that you got to the end of that item and you can stop. Another option is to use the Get Child and Get Next Item methods recursively.

 

 


___________________
Try to take over the world!
0 Kudos
Message 2 of 3
(24 Views)

Is this what you want? This gets all children of the clicked element and toggles their symbol. I went depth-first first which I could not get to work. Breadth-first was much easier.

 

Set symbol of all children in treeSet symbol of all children in tree

0 Kudos
Message 3 of 3
(12 Views)