Пример #1
0
 public static void RefreshAdded(TreeNode tn)
 {
     if (tn.Children != null && tn.Children.Count != 0)
     {
         foreach (TreeNode node in tn.Children)
         {
             node.AddedToTree = false;
             TreeWalker.RefreshAdded(node);
         }
     }
     tn.AddedToTree = false;
 }
Пример #2
0
        private static void Refresh()
        {
            TreeWalker.RefreshExpanded(structure);
            string selected = "";

            if (tv.SelectedNode != null)
            {
                selected = tv.SelectedNode.FullPath;
            }
            List <string> ExpandedNodes = new List <string>();

            if (tv != null && tv.Nodes != null && tv.Nodes.Count > 0 && tv.Nodes[0].Nodes != null && tv.Nodes[0].Nodes.Count > 0)
            {
                System.Windows.Forms.TreeNode Nodes1 = tv.Nodes[0];
                structure.Expanded = true;
                TreeWalker.collectExpandedNodes(Nodes1.Nodes[0], structure);
            }

            tv.Nodes.Clear();
            if (tv.Nodes == null || tv.Nodes.Count == 0 || !tv.Nodes.Contains(new System.Windows.Forms.TreeNode("ROOT")))
            {
                root = tv.Nodes.Add("ROOT");
            }
            tv.BeginUpdate();
            TreeWalker.RefreshAdded(structure);
            TreeWalker.Walk(structure, root);

            tv.EndUpdate();
            tv.Update();
            tv.Refresh();


            System.Windows.Forms.TreeNode Nodes2 = tv.Nodes[0];
            tv.Nodes[0].Expand();
            TreeWalker.ExpandNodes(Nodes2.Nodes[0], structure);
            if (selected != "")
            {
                tv.SelectedNode = TreeWalker.GetTreeViewNodeFromPath(tv.Nodes, selected, tv);
            }
            /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        }