标签:
转载:http://blog.sina.com.cn/s/blog_6abcacf5010138q5.html
private Hashtable NodesStatus = new Hashtable(); private string SelectNodeFullPath = string.Empty; /// <summary> /// /// </summary> /// <param name="nodes"></param> private void GetTreeNodesStatus(TreeNodeCollection nodes) { foreach (TreeNode node in nodes) { if (node.IsExpanded) { NodesStatus[node.FullPath] = true; } else { NodesStatus.Remove(node.FullPath); } if (node.IsSelected) { SelectNodeFullPath = node.FullPath; } GetTreeNodesStatus(node.Nodes); } } /// <summary> /// /// </summary> /// <param name="nodes"></param> private void SetTreeNodesStatus(TreeNodeCollection nodes) { foreach (TreeNode node in nodes) { if (NodesStatus[node.FullPath] != null) { node.Expand(); } if (node.FullPath == SelectNodeFullPath) { this.tvAuthFuction.SelectedNode = node; } SetTreeNodesStatus(node.Nodes); } } }
调用:
标签:
原文地址:http://www.cnblogs.com/zfanlong1314/p/4236437.html