递归展开tree所有节点

public static client void expandTree(FormTreeControl _formTreeControl, TreeItemIdx _treeItemIdx, int _toLevel = 0, int _level = 0)

{

    FormTreeItem    formTreeItem;

    TreeItemIdx     treeItemIdx = _treeItemIdx;

    int             level       = _level;

 

    while(treeItemIdx)

    {

        formTreeItem = _formTreeControl.getItem(treeItemIdx);

        level++;

 

        if (!formTreeItem.stateExpandedOnce())

        {

            _formTreeControl.expand(formTreeItem.idx());

        }

 

        if (_formTreeControl.getChild(formTreeItem.idx()))

        {

            if (!formTreeItem.children())

            {

                formTreeItem.children(true);

                _formTreeControl.setItem(formTreeItem);

                _formTreeControl.expand(formTreeItem.idx());

            }

 

            if (!_toLevel ||

                _toLevel > level)

            {

                SysFormTreeControl::expandTree(_formTreeControl,_formTreeControl.getChild(formTreeItem.idx()), _toLevel, level);

            }

        }

        else

        {

            if (formTreeItem.children())

            {

                formTreeItem.children(false);

                _formTreeControl.setItem(formTreeItem);

            }

        }

 

        treeItemIdx = _formTreeControl.getNextSibling(formTreeItem.idx());

    }

}

posted @ 2011-12-17 20:46  perock  阅读(1637)  评论(0编辑  收藏  举报