private void ToggleState(CellMouseEventArgs e)
        {
            GroupRendererData data = this.GetGroupRendererData(e.Cell);

            // Toggle the group state
            data.Grouped = !data.Grouped;

            Row r = e.Table.TableModel.Rows[e.Row];

            r.ExpandSubRows = !r.ExpandSubRows;
        }
        /// <summary>
        /// Gets the GroupRendererData specific data used by the Renderer from
        /// the specified Cell
        /// </summary>
        /// <param name="cell">The Cell to get the GroupRendererData data for</param>
        /// <returns>The GroupRendererData data for the specified Cell</returns>
        protected GroupRendererData GetGroupRendererData(Cell cell)
        {
            object rendererData = this.GetRendererData(cell);

            if (rendererData == null || !(rendererData is GroupRendererData))
            {
                rendererData = new GroupRendererData();

                this.SetRendererData(cell, rendererData);
            }

            return((GroupRendererData)rendererData);
        }
        /// <summary>
        /// Raises the Paint event
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPaint(PaintCellEventArgs e)
        {
            base.OnPaint(e);

            // don't bother if the Cell is null
            if (e.Cell == null)
            {
                return;
            }

            Rectangle checkRect = this.CalcCheckRect(this.LineAlignment, this.Alignment);

            if (!this.IsSubRow(e.Cell))
            {
                // Draw nothing if this row has no child rows
                if (e.Cell.Row.SubRows.Count > 0)
                {
                    // This is a parent row - draw a + or - in a box
                    GroupRendererData data = this.GetGroupRendererData(e.Cell);

                    DrawBox(e.Graphics, this.LineColorPen, checkRect);

                    if (data.Grouped)
                    {
                        DrawCross(e.Graphics, Pens.Gray, checkRect);
                    }
                    else
                    {
                        DrawMinus(e.Graphics, Pens.Gray, checkRect);
                        DrawHalfLine2(e.Graphics, this.LineColorPen, checkRect);
                    }
                }
            }
            else
            {
                // This is a subrow so either draw the end-line or the normal line
                if (this.IsLastRow(e.Cell))
                {
                    DrawEndLine2(e.Graphics, this.LineColorPen, checkRect);
                }
                else
                {
                    DrawLine2(e.Graphics, this.LineColorPen, checkRect);
                }
            }

            #region Draw text
            if (this.drawText)
            {
                string text = e.Cell.Text;

                if (text != null && text.Length != 0)
                {
                    Rectangle textRect = this.ClientRectangle;
                    textRect.X     += checkRect.Width + 1;
                    textRect.Width -= checkRect.Width + 1;

                    if (e.Enabled)
                    {
                        e.Graphics.DrawString(e.Cell.Text, this.Font, this.ForeBrush, textRect, this.StringFormat);
                    }
                    else
                    {
                        e.Graphics.DrawString(e.Cell.Text, this.Font, this.GrayTextBrush, textRect, this.StringFormat);
                    }
                }
            }
            #endregion
        }