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: 

How to use the TreeControl's active item indent level

I am trying to query the indent level of an item in a TreeControl when I double-click the item.  I have an event structure that captures the double-click event.  In the handler, I read the Active Item:Indent Level property but it returns an error:
 
Error 1135 occurred at Property Node (arg 1) in Viewer Main.vi
 
Possible reason(s):
LabVIEW:  The tree control's active item is not valid for this property.
Property Name: Active Item:Indent Level
 
Does anyone have code to show how to access the indent level for the Active Item?
 
Thanks,
-cb
0 Kudos
Message 1 of 7
(3,004 Views)
I think the Indent Level is the number of pixels child items are indented.
It seems to me you are trying to determine how many levels the items is?

If so, you can do that by querying an items parent, and repeat that for each
returned item, untill you get an error.

It's easier to give each item a tag that has this information in it. For
instance, a parent is called a, it's child is called a\b. You can put all
sorts of information in the tag, so you don't have to look it up when the
item is selected.

Regards,

Wiebe.


0 Kudos
Message 2 of 7
(2,997 Views)

Thanks Wiebe, that is very helpful.  I think that the TreeControl could be more programmatically robust.

-cb

0 Kudos
Message 3 of 7
(2,994 Views)

@10Degree wrote:

Thanks Wiebe, that is very helpful.  I think that the TreeControl could be more programmatically robust.


In what way? The error you got seemed like a perfectly valid error for an invalid operation. How is this not robust?
0 Kudos
Message 4 of 7
(2,985 Views)
smercurio_fc,
 
I may not be using the control properties correctly.  The help for Active Item:Indent Level indicates that it will return the Item Indent value for the active selected tree item.  The indent level indicates the depth in the tree at which the item exists.  For instance, a value of 2 indicates that the item is a Child of a Child of a Root node.  When I try to access the property, I get an error.  I have attached a simple VI (8.2.1) that shows the error and the basics of how I was trying to use it.  Can you point out my error or provide a corrected VI? 
 
Thank you,
-cb
0 Kudos
Message 5 of 7
(2,979 Views)
Your example is actually in 8.5, not 8.2.1. In any event, you're trying to access a property of the active item. The problem is that there's no active item (even if you double-click). That's why the error gets generated. Take a look at the example VI "Tree Enhancements" that ships with LabVIEW. It shows you how to access the indent level.
0 Kudos
Message 6 of 7
(2,974 Views)
Thank you.  That example clears up a number of questions.
0 Kudos
Message 7 of 7
(2,953 Views)