Пример #1
0
        public void Expand()
        {
            if (expanded)
            {
                return;
            }
            if (treeView == null)
            {
                expanded = true;
                return;
            }

            TreeViewCancelEventArgs args = new TreeViewCancelEventArgs(this, false, TreeViewAction.Expand);

            treeView.OnBeforeExpand(args);
            if (args.Cancel)
            {
                return;
            }

            TreeNode node        = this;
            TreeNode highestNode = node;

            for (; node != null; node = node.Parent)
            {
                node.expanded = true;
                highestNode   = node;
            }
            treeView.InvalidateDown(highestNode);
            treeView.OnAfterExpand(new TreeViewEventArgs(this, TreeViewAction.Expand));
        }
Пример #2
0
        private void Expand(bool byInternal)
        {
            if (is_expanded || nodes.Count < 1)
            {
                is_expanded = true;
                return;
            }

            bool     cancel    = false;
            TreeView tree_view = TreeView;

            if (tree_view != null)
            {
                TreeViewCancelEventArgs e = new TreeViewCancelEventArgs(this, false, TreeViewAction.Expand);
                tree_view.OnBeforeExpand(e);
                cancel = e.Cancel;
            }

            if (!cancel)
            {
                is_expanded = true;
                int count_to_next = CountToNext();

                if (tree_view != null)
                {
                    tree_view.OnAfterExpand(new TreeViewEventArgs(this));

                    tree_view.RecalculateVisibleOrder(this);
                    tree_view.UpdateScrollBars(false);

                    // ExpandBelow if we affect the visible area
                    if (visible_order < tree_view.skipped_nodes + tree_view.VisibleCount + 1 && ArePreviousNodesExpanded)
                    {
                        tree_view.ExpandBelow(this, count_to_next);
                    }
                }
            }
        }