LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way to access the TreeControl Child Text array?

Hi,

I am trying to access the 'child text' of a TreeControl at runtime (an array that contains all but the first columns for any given row).  I can set this through the 'Edit Tree items:Add Item' method, but I see no way to read it once it is set.


Thanks,

Neil
0 Kudos
Message 1 of 12
(4,627 Views)
It's not easy...you'll have to use the ActiveItemTag property of the tree control to set the tag to the row you're interested in looking at.  Then, in a loop, you'll need to use the ActiveCell property along with the ActiveCell.String property to get the strings in each column, one at a time, until you get an empty string.  If every item in your tree has a fixed number of child strings, you could do this in a For Loop, since you would know how many times it would need to run.
 
Let me know if you're still having trouble...I wrote a VI that takes this approach a while back to duplicate the contents of a Tree Control in another Tree Control.
 
Good luck,
-D
Message 2 of 12
(4,619 Views)
Worked great, thanks.
0 Kudos
Message 3 of 12
(4,607 Views)

Hi, I'm using the treecontrol. I have a subVi (LV 8.6.1) with an "Input Item Array" (an array that I use to populate the treecontrol by the 'Edit Tree items:Add Item' method) and an "Output Item Array". I don't found a method like the 'Edit Tree items:Add Item' to obtain that "Output Item Array". If it's of clear (I hope) can you help me?

thanks, fabio

0 Kudos
Message 4 of 12
(4,268 Views)
fabio.intel-

The “Edit Tree items:Add Item” can be found placing down a tree control.  On the block diagram, Rt click on the Tree Control Icon and select Create>>Invoke Node>>Edit Tree items>>Add Item.  Hope this helps.

Regards,

Mike S
NI AE
0 Kudos
Message 5 of 12
(4,249 Views)

Hi Make,

Is there a easy way to obtain the "Output Tree Array"?

Look at the VI.

thanks!!!

 

Regards, fabio

0 Kudos
Message 6 of 12
(4,238 Views)
I would suggest using an xml object rather than an array of clusters to store the data.  The array of clusters is not really a parent-child hierarchy, it is just a list that looks like a hierarchy.  An xml object is a true hierarchy.  Store the data in the xml object, and use iteration to fill in the tree control.  Storing the data in the control is ok, I have gotten in the habit of always creating data objects (xml, FV, etc) and using the front panel for displaying data only, not storing it.  A question of style I guess.
0 Kudos
Message 7 of 12
(4,220 Views)

I don't know xml, FV objects... but I'm going to study them.

Thanks a lot for your suggestion,

fabio

0 Kudos
Message 8 of 12
(4,208 Views)

When I typed FV I meant functional variable, another term that is used is action engine.  The LabVIEW Intermediate I class provides a very good introduction as to how to use these, so I can recommend it.  In earlier projects I used front panel controls to save data and states in my program, but after taking the Intermediate I class I found that using FV makes your code much more readable and modular.  Using this approach you primarily write data from the FV to the front panel and avoid reading data.

 

XML provides a data structure that is more flexible than a cluster.  Once you have defined a cluster, all you can do to extend it is create an array of the cluster.  For an XML object, you can add child nodes to any node in the tree, and add child nodes to those and so on.  I have noticed that XML is not as heavily used in the LabVIEW world as it is in the text software world.  In particular I have found that there are very few examples using the XML parser, although some people seem to be using the JKI EasyXML.  I am not knowledgable enough to know why it is not commonly used, maybe someone else can comment.

0 Kudos
Message 9 of 12
(4,197 Views)

This didn't work for me, I got empty strings though columns 0 and 1 have strings.

0 Kudos
Message 10 of 12
(2,145 Views)