AX – D365FO – Auto expand whole tree in FormTreeControl

If you have a Tree control on your form and want to expand the whole tree with all items and subitems at once, you can use the following static method:

SysFormTreeControl::expandTree(FormTreeControl _formTreeControl, TreeItemIdx _treeItemIdx, int _toLevel = 0,int _level = 0 )

For example to expand the whole tree from the root item to the inner most item:

SysFormTreeControl::expandTree(TreeCtrl, TreeCtrl.getRoot());
Or only from the current selection item down the tree:

SysFormTreeControl::expandTree(TreeCtrl, TreeCtrl.getSelection());

This article written by my friend Arun Garg: https://community.dynamics.com/ax/b/dynamicsaxsolutions/posts/auto-expand-whole-tree-in-formtreecontrol

Leave a comment