Example #1
0
 protected virtual void OnNodeExpanded(ExpandedEventArgs e)
 {
     if (this.NodeExpanded != null)
     {
         NodeExpanded(this, e);
     }
 }
Example #2
0
        internal protected virtual bool ExpandNode(TreeGridNode node)
        {
            if (!node.IsExpanded || this._virtualNodes)
            {
                ExpandingEventArgs exp = new ExpandingEventArgs(node);
                this.OnNodeExpanding(exp);

                if (!exp.Cancel)
                {
                    this.LockVerticalScrollBarUpdate(true);
                    this.SuspendLayout();
                    _inExpandCollapse = true;
                    node.IsExpanded   = true;


                    bool haschilds = false;
                    foreach (TreeGridNode childNode in node.Nodes)
                    {
                        if (childNode.Nodes.Count > 0)
                        {
                            haschilds = true;
                        }
                    }
                    if (!haschilds)
                    {
                        DataGridViewRow[] rowarray = new DataGridViewRow[node.Nodes.Count];
                        int idx = 0;
                        foreach (TreeGridNode childNode in node.Nodes)
                        {
                            Debug.Assert(childNode.RowIndex == -1, "Row is already in the grid.");
                            rowarray[idx]   = childNode;
                            childNode._grid = node._grid;
                            childNode.CheckQueuedDispose();
                            idx++;
                        }
                        base.Rows.InsertRange(node.RowIndex + 1, rowarray);
                    }
                    else
                    {
                        //TODO Convert this to a InsertRange
                        foreach (TreeGridNode childNode in node.Nodes)
                        {
                            Debug.Assert(childNode.RowIndex == -1, "Row is already in the grid.");

                            this.SiteNode(childNode);
                            //this.BaseRows.Insert(rowIndex + 1, childRow);
                            //TODO : remove -- just a test.
                            //childNode.Cells[0].Value = "child";
                        }
                    }

                    ExpandedEventArgs exped = new ExpandedEventArgs(node);
                    this.OnNodeExpanded(exped);
                    //TODO: Convert this to a specific NodeCell property
                    _inExpandCollapse = false;
                    this.LockVerticalScrollBarUpdate(false);
                    this.ResumeLayout(true);
                    this.InvalidateCell(node.Cells[0]);
                }

                return(!exp.Cancel);
            }
            else
            {
                // row is already expanded, so we didn't do anything.
                return(false);
            }
        }