Please enable JavaScript to view this site.

DAQFactory User's Guide

Navigation: 7 Pages and Components > 7.18 The Components > 7.18.9 Selection

7.18.9.2 Tree List Component

Scroll Prev Top Next More

This is an advanced component and only usable with scripting.  Because of this, you must name the component.  The component name can be assigned using the normal method or through the properties window for the component.  The properties window also allows you to enter an event sequence that is executed, just like events in other components, when the user double clicks on a tree item.  The event provides two private variables, strItemText which is the actual text that was clicked on, and ItemData which is a numeric value that you assigned to each item.   But of course you first must fill the tree list.  This can only be done with scripting with the following functions:

InsertItem(Text, Parent, Insert After, Data, [TextColor = RGB(0,0,0)]): Inserts a new item with the given text into the tree.  Returns a handle to the item which can be used for subsequent commands.  Parent is the parent item or 0 for the root.  Insert after is the item to insert this item after or 0 for the last item.  Data is a user definable value that is returned to you in the double click event.  You can optionally specify the color used for the text.  This should be in standard RGB encoding.  Use the RGB() function to help with this.  It defaults to black.

DeleteItem(Item): Deletes the given tree item.  Item is the handle of the desired item returned when you did InsertItem.

DeleteAllItems(): Clears the tree list.

Once you have some items in the tree, there are more functions to help:

EnsureVisible(Item): Scrolls the item list so that the given item is visible.  If the item is in a collapsed part of the tree, the necessary parts of tree will be expanded

Expand(Item): Expands the given item.  This is the same as the user clicking on the + to the left of the item.  Has no effect if the item does not have any children.

GetItemData(Item): returns the data associated with given Item handle.

GetItemText(Item): returns the text displayed for the given Item handle.

GetSelected(): returns the Item handle for the currently selected item, or 0 if nothing is selected.

SelectItem(Item): Selects the given item, in turn calling your event code.  This does the same thing as clicking on the item.  If the item is not visible, either because it is in a collapsed part of the tree or scrolled off the page, it will be brought into view.  If you call SelectItem() with an Item of 0, or an Item that doesn't exist, whatever is currently selected will be deselected.

SetItemData(Item, Data): allows you to change the data for the given Item handle.

SetItemText(Item, Text): allows you to change the data for the given Item handle.

SetItemTextColor(Item, Color): allows you to change the color for the given Item handle.

In addition to the above functions, there are a few variables that allows you to tweak the tree:

FontSize: sets the font size for all the text in the tree.  The default is 14.

HasLines: if true, then lines are drawn on the tree.  This defaults to 1.

IndentPixels: the number of pixels to indent at each level.  The default is 16.

Sorted: if true, the tree will be sorted on each level.  This defaults to 0 (false).  Note that if you set this to 0 after it has been sorted, the tree will remain sorted, though additionally added items will not be sorted.  If you set it to 1, existing items will be sorted.