LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading all of the the tree control text

Hi,
 
Is there a way to figure out which is the last column of a particular tree control item that contains any text?
 
Fedor.
0 Kudos
Message 1 of 7
(4,676 Views)
Do you already have the item tag of the row you're interested in?  If so, you can use the "ActiveItemTag" property of the tree to set that tag, then use a while loop and set the "ActiveColNum" property to '0' and read the "Cell String" property...if you get a non-empty string back, then set the ActiveColNum property to '1' and read the Cell String...keep doing this until you get an empty string for the Cell String value.  Once you get an empty string, you know the previous column was the last one that had any text in it.
 
I hope this helps...if you're still having trouble, please reply with a detailed description of the problem, along with a VI that demonstrates it, if possible.
 
Good luck,
-D
0 Kudos
Message 2 of 7
(4,654 Views)
Thanks Darren, but tree control allows to have an empty cell followed by a non-empty one, so this algorithm would stop at 1st empty cell in a row and miss any text that follows.
 
Fedor.
0 Kudos
Message 3 of 7
(4,645 Views)

That's a good point.  Does your tree have a horizontal scrollbar?  If not, then you could use the NumCols property of the tree to get the number of visible columns of the tree control, and that could be your upper limit on checking the cell strings of each column.  If it does have a horizontal scrollbar, however, I'm not really sure if there is a way to do what you want, other than to have a "max # of empty strings" threshold that, if you pass, you assume there aren't any more column strings.  But I'm guessing your tree already has a max number of columns, right?

-D

0 Kudos
Message 4 of 7
(4,642 Views)

NumCols property is indeed what I am using now, but I was trying to make a more generic routine that reads the text from the invisible columns as well for an arbitrary tree control.

I think it makes sense for NI to add another property, the column index of the last cell with text.

Fedor.

0 Kudos
Message 5 of 7
(4,639 Views)
P.S. the description for Active Cell:Active Column Number Property does say that value of -2 selects all columns, but setting it to -2 generates an error.

Message Edited by Fedor on 04-30-2007 11:43 AM

0 Kudos
Message 6 of 7
(4,638 Views)

Depending on what properties you're trying to read/write after setting the Active Column to "-2", you may get an error...for example, if you try to read the "Cell String" after setting the active column to -2, you'll get an error, since the Cell String is only a single string.  However, you get no error if you set the active column to -2, then set the cell font to "Bold"...in this case, all the columns of the active Tag row become bold.

I will file a product suggestion against the tree control that there be some easy way to determine the last column in a tree containing cell text.

-D

0 Kudos
Message 7 of 7
(4,632 Views)