LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Search a tree control for a name/label

I have a  list of names. Based on the name I want to add a number in the same row but in a different column. I am using a tree control, I cannot use a table for other reasons. I want it set up like so.

 

Name   Unit   Time

Carol   Ohm 

Callie    V

Susie   mV

 

So I search for the name Callie and when it finds it, put the time in. This is a lot harder than it seems. I tried using the GetTreeItem() function. I am at a dead end.

0 Kudos
Message 1 of 4
(2,960 Views)
Searching a tree is not a trivial task: numerous parametrs of searching functions make it hard to understand. However, CVI comes with an example that can help you in understanding how it works. I am attaching a modified version of this example in which I have added a column to the tree and use SetTreeCellAttribute (panelHandle, PANEL_TREE, rowIndex, colIndex, ATTR_LABEL_TEXT, "Some Text"); to write some text to it in the rows where the standard sample highlights the cell. Hope this can help you in approaching your problem.


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 4
(2,951 Views)

By the way, whenever you only want to do a simple search on a tree control, as in this example, and you don't care about starting points, direction, descendants vs. siblings, and all that other stuff that makes GetTreeItem complicated, you always have the option to use GetIndexFromValue instead. This is true for pretty much all the list functions -- they can also be used with tree controls for simple tasks.

 

Luis

0 Kudos
Message 3 of 4
(2,930 Views)

Actually, you should ignore my previous post. I just realized that GetIndexFromValue searches the value associated with the tree item, which is not the same thing as the item label. So in this case, there really is no alternative to GetTreeItem. Sorry about that.

 

Luis

0 Kudos
Message 4 of 4
(2,925 Views)