/// <summary> /// 递归展开结点 /// </summary> /// <param name="treeNodes">TreeView.TreeNodeCollection</param> /// <param name="currentDepth">当前已展开的深度</param> /// <param name="depth">要展开的深度</param> private static void ExpandDepth(TreeNodeCollection treeNodes, int currentDepth, int depth) { if (currentDepth > depth) { return; } foreach (TreeNode node in treeNodes) { node.Expand(); TreeViewZ.ExpandDepth(node.Nodes, ++currentDepth, depth); currentDepth--; } }
/// <summary> /// 展开树深度 /// </summary> /// <param name="tree">当前的树</param> /// <param name="depth">要展开的深度</param> public static void ExpandDepth(TreeView tree, int depth) { TreeViewZ.ExpandDepth(tree.Nodes, 0, depth - 1); }