LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Tree Control: How to Edit an Item

Solved!
Go to solution

I know how to create a tree. It's very pretty.

 

The next natural step is to edit something about it:

For this example, let's say that I have a top-level item called "Rob" and it has two children "Nora" and "Caleb". The names are the "Left Cell String" values and the Tags, let's just say. Nora is 4 years old, and Caleb is 1 so when I create the tree I make 1-D arrays of those values and put them in "Child Text".

 

Now, I leave the program running until early November, and the day of Nora's birthday I want to programmatically change the "4" to a "5".

 

There are Add Item and Delete Item methods, but no Edit Item method.

 

Call me perplexed. This is going on the list of 10 Things.

 

In the mean time, would anyone have an answer to my quandry? Thanks in advance.

 

Follow-up: When I invoke Add Item, I get a string output. What is this? The assigned Tag, I assume? The help does not mention it. This is a trick question, because I actually don't believe that is possible, given how the Add Item function operates when you call it twice in succession with the same inputs.

 

P.S. "You are an idiot" is definitely a reasonable response to this post. 🙂

 

 

0 Kudos
Message 1 of 6
(11,082 Views)
Solution
Accepted by 10Things_Rob

I've played around a bit with tree controls. You're right, they're not exactly intuitive.

Here's an example of one I got going fairly reliably...http://decibel.ni.com/content/servlet/JiveServlet/download/3968-1-4990/m3u%20playlist%20generator.ll...

 

I think what you need to do is set the active tag to the one you want to edit (Property Node) "Active Item:Tag"

Then you can write to the property "Active Cell:String"

Troy - CLD "If a hammer is the only tool you have, everything starts to look like a nail." ~ Maslow/Kaplan - Law of the instrument
Message 2 of 6
(11,065 Views)

When I invoke Add Item, I get a string output. What is this? The assigned Tag, I assume?


Yes, I believe it is. The help says (under "Edit Tree Items:Add Item Method" Parameters-output) Tag for the new item.


given how the Add Item function operates when you call it twice in succession with the same inputs.


The help also says (under "Edit Tree Items:Add Item Method" Parameters-Child Tag) If an existing tag already uses that string, LabVIEW appends a number to the string to create a unique tag for the new item.

Is this the behavior you are seeing?

Troy - CLD "If a hammer is the only tool you have, everything starts to look like a nail." ~ Maslow/Kaplan - Law of the instrument
0 Kudos
Message 3 of 6
(11,060 Views)

given how the Add Item function operates when you call it twice in succession with the same inputs.


The help also says (under "Edit Tree Items:Add Item Method" Parameters-Child Tag) If an existing tag already uses that string, LabVIEW appends a number to the string to create a unique tag for the new item.

Is this the behavior you are seeing?


 

Yes, I am but here's what caught my attention - when I added Items as children. In the first of the two consecutive calls, two items were added as children. Then the second call, the new duplicate item was created with a new tag. But the two original children MOVED to be under the new item and then two duplicate children were created. See enclosed (v 8.6)

0 Kudos
Message 4 of 6
(11,051 Views)

Troy K,

 

Thanks that worked. But let me add something for those who may read this later:

 

If you want to change one of the "Child Text" elements, you will have to use "ActiveColNum" to specify which column you want to change the text of.

 

 

Message 5 of 6
(11,045 Views)

you will have to use "ActiveColNum" to specify which column you want to change the text of.


Yup, neglected to mention that. Knew you'd work it out. More satisfying that way (and I was too lazy to confirm/type it).

Troy - CLD "If a hammer is the only tool you have, everything starts to look like a nail." ~ Maslow/Kaplan - Law of the instrument
0 Kudos
Message 6 of 6
(11,042 Views)