The Tree Element and Table Element are close cousins. Many of the parameters found in the Table Element apply to Tree Elements. In particular the heading information, column widths, etc..
Table element the
Tree element uses a "helper class" that represents the tree data structure. A "table" is a simple 2 dimensional array, but a tree is a bit more complex, thus an additional data structure is needed so that you can build your tree and then pass it to the
The order of operations to make a tree is to take these steps:
- Get a TreeData Object
- "Insert" data into the tree
- Pass the filled in TreeData object to Tree Element
Tree element will return an event when an item is selected if the
enable_events parameter is set to
List of the currently selected items. These are the keys from the
TreeData class that was used to create/update the tree..
One of the best way to learn about the complex elements is to use the Demo Programs, Cookbook and other additional materials.
To "insert" data into the tree the TreeData method Insert is called.
To indicate insertion at the head of the tree, use a parent key of "". So, every top-level node in the tree will have a parent node = ""
This code creates a TreeData object and populates with 3 values
Note that you can use the same values for display_text and keys. The only thing you have to watch for is that you cannot repeat keys.
When reading a window the Table Element will return a list of rows that are selected by the user. The list will be empty if no rows are selected.
Icons on Tree Entries
If you wish to show an icon next to a tree item, then you specify the icon in the call to
Insert. You pass in a filename or a Base64 bytes string using the optional
Here is the result of showing an icon with a tree entry.