TreeView
TreeView
The TreeView is a control object that displays data as a branched list within a parent-child hierarchy.
This object allows the operator to easily navigate complex structures (facility hierarchy, menu trees, recipe categories) and select an item (node) from them.
Common Use Cases
- Navigation Menu: Creating a multi-level menu such as “Alarms,” “Reports” (with sub-items like “Daily Report,” “Weekly Report”), and “Settings.”
- Facility Hierarchy: Visually branching a facility structure, e.g., Facility -> Production Area 1 -> Machine A -> Motor 1.
- Categorization: Listing recipes or products by separating them into categories (e.g., “Product Type A,” “Product Type B”).
Basic Configuration and Operation
The TreeView object works with a collection of items called Nodes.
1. Defining Nodes (Static Method – Advanced Panel)
- Go to the object’s Advanced panel.
- Open the Nodes (Collection) property. Here, you manually add main nodes and their child nodes at design time.
2. Managing Interaction (Properties Panel)
- Which node the operator has selected is captured via the Index and Index Changed properties in the Properties panel.
Properties Panel – Key Properties
The Value section of this object generally focuses on managing the event triggered by a selection or the selection index, rather than the node object itself.
Value
- Index:
- Used to identify the currently selected node.
- If the index value is bound to a tag, the index of the node clicked by the operator can be sent to the PLC.
- Conversely, if the PLC changes this index, the TreeView automatically selects the corresponding node at runtime.
- Node Tags:
- When the CheckBoxes property in the Advanced panel is active, a new field appears under the Value category for each defined Node.
- Function: You can bind the checked status (Checked / Unchecked) of each individual node directly to a BOOL tag.
- Screen -> PLC: When the operator checks the box, the connected tag becomes True (or 1). When unchecked, it becomes False (or 0).
- PLC -> Screen: If the tag is set to True by the PLC, the corresponding box in the tree is automatically checked.
Events
- Index Changed:
- The defined function is triggered whenever the selected node changes.
- Use Case: Changing the screen page based on the selected node or displaying status information for the selected machine in a side panel.
Advanced Panel – Key Properties
- Nodes (Collection)
- The place where you build the static hierarchy of the tree. Each node has sub-properties such as Text, Name, and Tag.
- CheckBoxes
- If set to True, a checkbox appears next to each node. This allows for multiple selections, similar to a CheckedListBox. Tags can be defined for these nodes in the properties screen.
- ShowLines
- If True (Recommended), draws connecting lines between parent and child nodes to visually indicate the hierarchy.
- ShowPlusMinus
- If True (Recommended), displays expand/collapse (+/-) icons next to nodes that have child nodes (branches).
- ShowRootLines
- If True, displays connecting lines for the top-level (root) nodes as well.
- ImageList
- Allows you to assign icons (e.g., closed folder, open folder, machine icon) to nodes in the tree by connecting to an ImageList component.
- ImageIndex / SelectedImageIndex
- Determines which icon from the ImageList (based on index number) is used for the normal state (ImageIndex) and the selected state (SelectedImageIndex).
Common Usage Example
Example: Category Selection for Reporting (Using CheckBoxes)
- Go to the Advanced panel and set the CheckBoxes property to True.
- Statically populate the Nodes collection (e.g., “Report 1”, “Report 2”, “Report 3”).
- In the Properties screen, define a BOOL tag for each Node.
- Add a “Get Report” button to the screen.
- Add a script execution function to the Mouse Down event of the “Get Report” button.
- Logic: The script checks the tags associated with the nodes.
- It generates reports based on the checked nodes.
Result: The operator checks the desired areas from the tree to include in the report and presses the “Get Report” button to generate the specific data.
