SetSelectedNode() private method

private SetSelectedNode ( TreeNode node, bool loading ) : void
node TreeNode
loading bool
return void
Example #1
0
        public void RemoveAt(int index)
        {
            TreeNode node = this._list[index];

            if (this._updateParent)
            {
                TreeView owner = node.Owner;
                if (owner != null)
                {
                    if (owner.CheckedNodes.Count != 0)
                    {
                        UnCheckUnSelectRecursive(node);
                    }
                    else
                    {
                        for (TreeNode node2 = owner.SelectedNode; node2 != null; node2 = node2.Parent)
                        {
                            if (node2 == node)
                            {
                                owner.SetSelectedNode(null);
                                break;
                            }
                        }
                    }
                }
                node.SetParent(null);
            }
            this._list.RemoveAt(index);
            this._version++;
            this.Log.Add(new LogItem(LogItemType.Remove, index, this._isTrackingViewState));
        }
Example #2
0
        public void Clear()
        {
            if (this.Count == 0)
            {
                return;
            }
            if (_owner != null)
            {
                TreeView owner = _owner.Owner;
                if (owner != null)
                {
                    // Clear checked nodes if necessary
                    if (owner.CheckedNodes.Count != 0)
                    {
                        owner.CheckedNodes.Clear();
                    }
                    TreeNode current = owner.SelectedNode;
                    // Check if the selected item is under this collection
                    while (current != null)
                    {
                        if (this.Contains(current))
                        {
                            owner.SetSelectedNode(null);
                            break;
                        }
                        current = current.Parent;
                    }
                }
            }
            foreach (TreeNode node in _list)
            {
                node.SetParent(null);
            }

            _list.Clear();
            _version++;
            if (_isTrackingViewState)
            {
                // Clearing invalidates all previous log entries, so we can just clear them out and save some space
                Log.Clear();
            }
            Log.Add(new LogItem(LogItemType.Clear, 0, _isTrackingViewState));
        }
Example #3
0
        protected virtual void LoadViewState(object savedState)
        {
            if (savedState == null)
            {
                return;
            }

            object[] states = (object[])savedState;
            ViewState.LoadViewState(states [0]);

            if (tree != null && SelectedFlag)
            {
                tree.SetSelectedNode(this, true);
            }

            if (!PopulateOnDemand || Populated)
            {
                ((IStateManager)ChildNodes).LoadViewState(states [1]);
            }
        }
Example #4
0
        public void RemoveAt(int index)
        {
            TreeNode node = _list[index];

            if (_updateParent)
            {
                TreeView owner = node.Owner;
                if (owner != null)
                {
                    if (owner.CheckedNodes.Count != 0)
                    {
                        // We have to scan the whole tree of subnodes to remove any checked nodes
                        // (and unselect the selected node if it is a descendant).
                        // That could badly hurt performance, except that removing a node is a pretty
                        // exceptional event.
                        UnCheckUnSelectRecursive(node);
                    }
                    else
                    {
                        // otherwise, we can just climb the tree up from the selected node
                        // to see if it is a descendant of the removed node.
                        TreeNode current = owner.SelectedNode;
                        // Check if the selected item is under this collection
                        while (current != null)
                        {
                            if (current == node)
                            {
                                owner.SetSelectedNode(null);
                                break;
                            }
                            current = current.Parent;
                        }
                    }
                }
                node.SetParent(null);
            }

            _list.RemoveAt(index);
            _version++;
            Log.Add(new LogItem(LogItemType.Remove, index, _isTrackingViewState));
        }
Example #5
0
 public void Clear()
 {
     if (this.Count != 0)
     {
         if (this._owner != null)
         {
             TreeView owner = this._owner.Owner;
             if (owner != null)
             {
                 if (owner.CheckedNodes.Count != 0)
                 {
                     owner.CheckedNodes.Clear();
                 }
                 for (TreeNode node = owner.SelectedNode; node != null; node = node.Parent)
                 {
                     if (this.Contains(node))
                     {
                         owner.SetSelectedNode(null);
                         break;
                     }
                 }
             }
         }
         foreach (TreeNode node2 in this._list)
         {
             node2.SetParent(null);
         }
         this._list.Clear();
         this._version++;
         if (this._isTrackingViewState)
         {
             this.Log.Clear();
         }
         this.Log.Add(new LogItem(LogItemType.Clear, 0, this._isTrackingViewState));
     }
 }