class="csharpcode">public static void ExpendPointTypeNode(TreeList _tree, NodeType _type) { if (_tree == null) return; CrossThreadOperate.InvokeControlAction<TreeList>(_tree, t => { foreach (TreeListNode _node in _tree.Nodes) { if ((NodeType)_node.Tag == _type) { ProcessNodeExpend(_node); continue; } ExpendPointTypeNode(_tree, _node, _type); } }); } private static void ProcessNodeExpend(TreeListNode _node) { TreeListNode _currentNode = _node; while (_currentNode.ParentNode != null) { _currentNode.ParentNode.Expanded = true; _currentNode = _currentNode.ParentNode; } } private static void ExpendPointTypeNode(TreeList _tree, TreeListNode _node, NodeType _type) { CrossThreadOperate.InvokeControlAction<TreeList>(_tree, t => { foreach (TreeListNode _n in _node.Nodes) { if ((NodeType)_n.Tag == _type) { ProcessNodeExpend(_n); continue; } ExpendPointTypeNode(_tree, _n, _type); } }); }
使用:
CabTreeOperate.ExpendPointTypeNode(this.cabTreeControl.Tree, NodeType.Cab);