02-02-2009 11:18 AM
Happy Groundhog Day everybody! From what I heard on the news, the groundhog came out of his burrow and saw a For Loop, which means there will be at least 50 more weeks of nuggets. Way to go, groundhog!
Today's nugget involves the Tree Control. As you may have seen in my first nugget of 2009, my favorite feature of LabVIEW 7.0 was the Tree Control. One of the problems I always had with the Tree Control was figuring out when to show the scrollbars of the tree. It was relatively easy to figure out if I needed to show the vertical scrollbar--if there were more visible tree items than there were visible tree rows, show the vertical scrollbar. Figuring out whether or not to show the horizontal scrollbar, however, was much more difficult. Here's the hackish procedure I used to use:
After doing all of this, I would just always show the horizontal scrollbar. It worked reasonably well, but I always felt kinda dirty using that technique, and most of the time, a horizontal scrollbar was showing when it wasn't necessary. And it also felt weird that when it was necessary, you would often be able to scroll way past the visible text into empty space.
All of this pain and suffering went away in LabVIEW 8.0. In 8.0 and later, there is a utility VI in vi.lib\tree called Tree_ShowScrollBar.vi. Now I just stick this VI after any operation in which I'm adding, removing, editing, or expanding tree items, and it figures out whether or not it needs to show the vertical and horizontal scrollbars for the tree.
-D
P.S. - Check out past nuggets here.
02-02-2009 12:23 PM
This is a great nugget!
I wish I had found out about this before today.
Thanks.
02-05-2009 10:10 AM
02-05-2009 10:11 AM