Creating a Tree Control
- 已更新2026-05-29
- 閱讀時間為 3 分鐘
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.
- Add a tree control to the front panel from .
-
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.
-
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.
-
Set the hierarchy of the items in the tree control by indenting items.
Option Description 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.
- 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.
- Optional: Set the number of items a user can select in the tree control: right-click the tree control and choose a Selection Mode.
-
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 Mode Block 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 .
You can also use the TreeControl methods to add items to a tree control programmatically.
相關內容
- Indenting Tree Control Items
- Adding Symbols to Listboxes and Tree Controls
Add symbols to items in a LabVIEW listbox or tree control to make items visually distinct within the user interface.
- Disabling or Enabling Listbox and Tree Control Items
- Deleting Rows in Listboxes and Tree Controls
- Setting Expand/Contract Symbols in Tree Controls
- Setting Case Sensitivity in Listboxes and Tree Controls
- Configuring Run-Time Drag-and-Drop Behavior for Text-Based Controls
- Setting the Number of Items You Can Select in Listboxes and Tree Controls at Run Time
- Creating a Case Structure to Execute Conditional Code