Exemple #1
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);
                    }
                }
            }
        }