转载: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);
            }
        }
    }
View Code

相关文章:

  • 2022-12-23
  • 2021-07-02
  • 2022-01-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-18
  • 2021-07-31
  • 2021-08-31
  • 2022-12-23
  • 2021-10-14
相关资源
相似解决方案