Ejemplo n.º 1
0
        private void UpdateUI()
        {
            List <string> expandedNodes = Helpers.GetExpandedNodes(TreeViewItems.Nodes);

            // Dirty trick to prevent flickering
            this.BackgroundImage = new Bitmap(TreeViewItems.Width, TreeViewItems.Height);
            TreeViewItems.DrawToBitmap((Bitmap)this.BackgroundImage, new Rectangle(TreeViewItems.Location, TreeViewItems.Size));

            TreeViewItems.Visible = false;
            TreeViewItems.BeginUpdate();
            TreeViewItems.Nodes.Clear();
            foreach (Group g in groups.OrderBy(grp => grp.Name))
            {
                AddGroupNode(g, null);
            }

            if (selectedNode != null)
            {
                SelectNode(TreeViewItems.Nodes, selectedNode.Text);
            }
            Helpers.SetExpandedNodes(TreeViewItems.Nodes, expandedNodes);

            TreeViewItems.EndUpdate();
            TreeViewItems.Visible = true;
            this.BackgroundImage  = null;
        }