Use the tree control to give users a hierarchical list of items from which to select on the front panel. Use a Case Structure on the block diagram to create code that handles selections in the tree.

You organize the items you enter in the tree control into hierarchical groups of items, or nodes.

To create a tree control, complete the following steps.

  1. Add a tree control to the front panel from Controls » Style » List, Table & Tree » Tree.
  2. Use the Labeling tool to enter an item name in the tree control and press the Enter key.
    LabVIEW creates a unique tag for the item. The default tag is the text in the first cell that contains text, starting from the left. If an existing tag already uses that string, LabVIEW appends a number to the string to create a unique tag for the new item.

    You use this tag to modify items or to gather information about items programmatically.

  3. Repeat step 2 for each item you want to enter.
    LabVIEW creates each new item at the same hierarchical level as the item above it. If there is no item above the new item, LabVIEW creates the item at the topmost hierarchical level.
  4. Set the hierarchy of the items in the tree control by indenting items.
    OptionDescription
    Indent an item
    • Select the item and press the period . key.
    • Right-click the item and select Indent Item.
    Move an item to the left (outdent)
    • Select the item and press the comma , key.
    • Right-click the item and select Outdent Item.
  5. Optional: Configure the tree control: right-click items and choose among the available options.
    You can add symbols and edit, disable, and delete items in a tree control. You also can set the expand/contract symbol type, case sensitivity, and item dragging for a tree control.
  6. Optional: Set the number of items a user can select in the tree control: right-click the tree control and choose a Selection Mode.
  7. Create a Case Structure on the block diagram to handle the selected item with conditional code for each item.
    How a tree control behaves on the block diagram depends on the selection mode for the tree.
    Selection ModeBlock Diagram Behavior
    0 or 1 Item or 1 Item Tree control appears as a string.

    The data value for a single-selection tree control is the unique tag of the currently selected option.

    0 or More Items or 1 or More Items Tree control appears as an array of strings.

    The value(s) in the array represent the currently selected item(s). If no item is selected, the value is an empty array.

    To change the data type between scalar and array data, right-click the tree control on the front panel and select Selection Mode » Data Type.

You can also use the TreeControl methods to add items to a tree control programmatically.