Block UI Styler > Block Catalog > Special options > Tree List
Tree List properties and callbacks
The Tree List block supports functionality to do the following (full callback/API reference).
Insert nodes and child nodes, and edit and delete them
You need the following APIs to create and insert a node:
- CreateNode API — creates a node on a tree. (See Example — CreateNode API.)
- InsertNode API — inserts the node created using the CreateNode API in the tree. The InsertNode API requires parameters such as parent node and reference node. For example, a valid parent node parameter in the API allows the new node to become a child of that parent node. (See Example — InsertNode API.)
Actions such as editing the node, or deleting it, cannot be performed unless the node is inserted into the tree. It cannot have parent, sibling, or child nodes until inserted.
A customized sorting order can be specified using a separate callback for sorting the nodes. When the node is inserted, it invokes the node-insert callback in which specific ordering decisions can be made.
Edit a node's label
Editing modes documented:
- Text edit —
OnEndLabelEditCallback: invoked when a label is edited, and it checks if the edited text is valid. If it is not, the label edit is reverted. - List box edit — you can provide a list of options for a drop-down list using the
SetEditOptionsmethod available on the tree. Use this method withinAskEditControlCallback.AskEditControlCallback: invoked when a node is selected for edit and it specifies if the control type is a list box or a combo box. (See Example — AskEditControlCallback.)OnEditOptionSelectedCallback: invoked when an option available in the list box is selected, and it accepts or rejects the selection. (See Example — OnEditOptionSelectedCallback.)
- Combo box edit — similar to a list box edit, but it also allows entering text in the combo box. This text need not be part of the available options in the control box. Uses
AskEditControlCallback(specifies control type) and evaluates the selection or the specified text.
Provide a menu and submenu for the tree or for each node
Menus and submenus can be created for individual nodes or the entire tree on a right click. The callbacks allow creating menus and setting menu items, and making decisions for the selected menu option.
OnMenuCallback: invoked and displays a menu when a node or any other part of a tree is right-clicked. The node object is one of the parameters of the callback and its value is null if the user clicks anywhere on the tree other than the node. Create menus and submenus within this callback and set the menus to the tree usingCreateMenuandSetMenumethods available on the tree (refer toNXOpen.BlockStyler.TreeListMenu). Each menu item corresponds to a command; provide a unique ID for each menu item — this ID is used when the menu item is selected. (See Example — OnMenuCallback.)OnMenuSelectionCallback: invoked when a command on a menu is selected, and it performs the command action based on the unique ID of the menu item. (See Example — OnMenuSelectionCallback.)
Specify a label, icon, and a tooltip for each node
The node consists of an entire row in the list.
- The first cell of the node (first column) can display a label or an icon, or both. The icon in this cell is called a display icon, and can change when selected.
- The node can also display a state icon adjacent to the display icon — an example is a check box icon that displays the state of selection of the node.
- The other cells can display either a label or an icon.
ToolTipTextCallback: invoked when the mouse hovers over a node; returns a text string as a tool tip.
Customize the color of each node
When the color of the node text is customized, it is applied to the entire row of the node. The background color is governed by the customer default settings and cannot be altered. The node can have state icons such as checked and unchecked state icons.
Specify the state icon for each node
You can specify a state icon for each node. Examples of states are checked and unchecked.
StateIconNameCallback: invoked when the node state is set by theSetStatemethod on the Node object, and the value is set to any integer other than 1 and 2. This callback is called only once for any given node state. (See Example — StateIconNameCallback.)
Provide data to each node (e.g. a feature)
Each node can hold data such as a feature, a PMI object, a string, integer, vector, or any other type of object specified in NXOpen.PropertyContainer.PropertyType. Each data object is paired with a unique property name, and the pair forms an entry in the NXOpen.DataContainer. Multiple entries can be specified as long as each property name is unique among the entries in the NXOpen.DataContainer. Entries with the property name Data are considered primary data and are used by NX for operations such as cross selection.
Entries in the NXOpen.DataContainer object must be added using the corresponding data-type setters, e.g.:
- To add a tagged object:
DataContainer.AddTaggedObject("Data", taggedObject) - To add a string:
DataContainer.AddString("BookKeeping", "Hello")
To complete setting the data, you must delete the NXOpen.DataContainer object. Explicit setting of the NXOpen.DataContainer object to nodes is not required. (See Example — using the GetNodeData method.)
Select the node for a displayable object to highlight it in the graphics window
When a node is tagged with object data using the corresponding property name Data, NX highlights the object (e.g. a feature or PMI object) when the node is selected. (See Example — using the GetNodeData method.)
Specify resize policy for columns
The tree list allows insertion of columns with specific resize policies governed by the ColumnResizePolicy property.
Behavior table for ColumnResizePolicy:
| Behavior | ConstantWidth | ResizeWithContents | ResizeWithTree |
|---|---|---|---|
| Column resizes with node text width | No | Yes | No |
| If no node is added, column width can be resized using the mouse | Yes | Yes | No |
| After adding the node, column can be resized using the mouse | Yes | No | No |
| Double-click automatically resizes the column | Yes | No | No |
| Column width resizes with the tree width | No | No | Yes |
The combination of tree properties and node insertion mechanism allows the tree to behave like a table. This can be achieved by setting the ShowExpandCollapseMarker property on the tree to False and inserting a node whose parent node is null.
Allow or disallow sorting nodes
You can provide customized callbacks to sort nodes. These callbacks must be registered and are called when the node is inserted in the tree.
Allow or disallow dragging and dropping nodes within a list
IsDragAllowedCallback: invoked when a node is dragged, and allows or disallows the dragging action.IsDropAllowedCallback: invoked when a node is dragged onto another node and displays a symbol showing whether a drop at the latter node is valid or not.
Allow or disallow expanding and collapsing nodes
The ShowExpandCollapseMarker property allows the expansion and collapse of a node when set to True.
OnExpandCallback: invoked at the first expansion of a node.
Allow or disallow showing and hiding columns
You can use the NXOpen API in automation code to show or hide inserted columns. Inserted columns are displayed by default. (Refer to NXOpen.BlockStyler.Tree class.)
Provide the callback for default action on the node
OnDefaultAction: provide behavior in this callback, which is invoked when any node on the tree is double-clicked.
Select or deselect an item from the Tree List
OnSelectCallback: invoked whenever an item is selected or deselected from the Tree List.
Look up more details (linked examples in source book — titles only, not fetched in this pass)
- Tree List (block catalog entry)
- Example — CreateNode API
- Example — InsertNode API
- Example — AskEditControlCallback
- Example — OnEditOptionSelectedCallback
- Example — OnMenuCallback
- Example — OnMenuSelectionCallback
- Example — StateIconNameCallback
- Example — using the GetNodeData method
- (additional examples referenced by the book but not enumerated in the text extracted for this page)
Summary: full callback/API list found on this page
CreateNode, InsertNode, OnEndLabelEditCallback, AskEditControlCallback, OnEditOptionSelectedCallback, OnMenuCallback, OnMenuSelectionCallback, ToolTipTextCallback, StateIconNameCallback, IsDragAllowedCallback, IsDropAllowedCallback, OnExpandCallback, OnDefaultAction, OnSelectCallback, plus supporting methods SetEditOptions, CreateMenu, SetMenu, SetState, DataContainer.AddTaggedObject, DataContainer.AddString, and the ColumnResizePolicy / ShowExpandCollapseMarker properties. Related classes: NXOpen.BlockStyler.TreeListMenu, NXOpen.BlockStyler.Tree, NXOpen.PropertyContainer.PropertyType, NXOpen.DataContainer.
Source: https://docs.sw.siemens.com/en-US/doc/209349590/PL20220512394070742.blockstyler/tree_list_ref · retrieved 2026-07-07