From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Copying Tree Contents

Solved!
Go to solution

Hello All,

 

I have been struggling for days trying to achieve this one task and I have decided to turn to the experts for help. I am a novice LabVIEW programmer so I need all the help I can get.

 

Basically I am trying to duplicate the contents of a selected tree with a new Parent String.

 

I did some research and found some information on the LabVIEW tree control but I did not have any luck trying to make it work for me.

 

If someone could point me in the right direction or even better give me an example, I would appreciate it.

 

Attached is a VI that I started and after numerous attempts I gave up.

 

PS. Is there a property node that provides the selected Tree Item + a  way to tell if the selected Item is a Parent or a Child?

 

Thank You

0 Kudos
Message 1 of 10
(2,375 Views)

Searching the forums, I found this thread.  Copying data between tree controls  

 

That might get you started.

0 Kudos
Message 2 of 10
(2,361 Views)

This copies item between the Tree controls. I want to duplicate the selected Parent in the same tree.

For example: Select Parent 1 and click duplicate (Duplicates parent 1 and its child in the same tree, the Parent name would be different) I would pass the parent name through a SubVI dialog box.

0 Kudos
Message 3 of 10
(2,354 Views)

I said it would get you started, not that it would exactly do what you want it to do.

 

You'd probably be using many of the same property and invoke nodes, but in a different arrangement.

0 Kudos
Message 4 of 10
(2,330 Views)

Hello, I understand that this won't do exactly what i want. Is there a property node in Tree control that tells me the selected item, if the selected item is a parent or a child?

 

I guess this is where I am stuck.

 

Thank You

0 Kudos
Message 5 of 10
(2,292 Views)

In the link I placed earlier, the VI there has the ActiveItemTag property node.  It has an indent level property.  If you look at all the tags, any item that has an indent level that is less than the indent level for the one after it must be a parent.  If the indent level is the same or greater than the item after it, than that active tag is only a child.

0 Kudos
Message 6 of 10
(2,284 Views)

Thank You for the Help. I was able to figure it out. I have to apply some logic to determine if the parent doesn't have any child, not to copy because there is nothing to copy, but the main code that I needed is there.

0 Kudos
Message 7 of 10
(2,279 Views)
Solution
Accepted by topic author PGgautam1

You should use an event structure, no need to continuously poll the button. See below. Also some basic error checking should be done.

 

Rough draft, can be improved.

 

snip.png

 

2018 Version attached.

 

mcduff

Message 8 of 10
(2,241 Views)

Hello mcduff,

 

Thanks for the feedback. my actual code is event driven. I just threw something together to get the point across in the forum. I do like what you have done here though, I did not know about the get child vi library so that is helpful.

 

Thanks

0 Kudos
Message 9 of 10
(2,224 Views)

@PGgautam1 wrote:

Hello mcduff,

 

Thanks for the feedback. my actual code is event driven. I just threw something together to get the point across in the forum. I do like what you have done here though, I did not know about the get child vi library so that is helpful.

 

Thanks


Use VIPM to install “Hidden Gems” of the VI library; that vi and some other tree gems will be accessible on your palettes.

 

mcduff

Message 10 of 10
(2,219 Views)