protected override void OnPaintBackground(PaintEventArgs e)
        {
            base.OnPaintBackground(e);
            int cellBorderWidth = this.CellBorderWidth;

            TableLayout.ContainerInfo       containerInfo   = TableLayout.GetContainerInfo(this);
            TableLayout.Strip[]             columns         = containerInfo.Columns;
            TableLayout.Strip[]             rows            = containerInfo.Rows;
            TableLayoutPanelCellBorderStyle cellBorderStyle = this.CellBorderStyle;

            if ((columns != null) && (rows != null))
            {
                int       num6;
                int       length           = columns.Length;
                int       num3             = rows.Length;
                int       num4             = 0;
                int       num5             = 0;
                Graphics  g                = e.Graphics;
                Rectangle displayRectangle = this.DisplayRectangle;
                Rectangle clipRectangle    = e.ClipRectangle;
                bool      flag             = this.RightToLeft == RightToLeft.Yes;
                if (flag)
                {
                    num6 = displayRectangle.Right - (cellBorderWidth / 2);
                }
                else
                {
                    num6 = displayRectangle.X + (cellBorderWidth / 2);
                }
                for (int i = 0; i < length; i++)
                {
                    int y = displayRectangle.Y + (cellBorderWidth / 2);
                    if (flag)
                    {
                        num6 -= columns[i].MinSize;
                    }
                    for (int j = 0; j < num3; j++)
                    {
                        Rectangle bound = new Rectangle(num6, y, columns[i].MinSize, rows[j].MinSize);
                        Rectangle rect  = new Rectangle(bound.X + ((cellBorderWidth + 1) / 2), bound.Y + ((cellBorderWidth + 1) / 2), bound.Width - ((cellBorderWidth + 1) / 2), bound.Height - ((cellBorderWidth + 1) / 2));
                        if (clipRectangle.IntersectsWith(rect))
                        {
                            using (TableLayoutCellPaintEventArgs args = new TableLayoutCellPaintEventArgs(g, clipRectangle, rect, i, j))
                            {
                                this.OnCellPaint(args);
                            }
                            ControlPaint.PaintTableCellBorder(cellBorderStyle, g, bound);
                        }
                        y += rows[j].MinSize;
                        if (i == 0)
                        {
                            num5 += rows[j].MinSize;
                        }
                    }
                    if (!flag)
                    {
                        num6 += columns[i].MinSize;
                    }
                    num4 += columns[i].MinSize;
                }
                if ((base.HScroll || base.VScroll) || (cellBorderStyle == TableLayoutPanelCellBorderStyle.None))
                {
                    ControlPaint.PaintTableControlBorder(cellBorderStyle, g, displayRectangle);
                }
                else
                {
                    Rectangle rectangle5 = new Rectangle((cellBorderWidth / 2) + displayRectangle.X, (cellBorderWidth / 2) + displayRectangle.Y, displayRectangle.Width - cellBorderWidth, displayRectangle.Height - cellBorderWidth);
                    switch (cellBorderStyle)
                    {
                    case TableLayoutPanelCellBorderStyle.Inset:
                        g.DrawLine(SystemPens.ControlDark, rectangle5.Right, rectangle5.Y, rectangle5.Right, rectangle5.Bottom);
                        g.DrawLine(SystemPens.ControlDark, rectangle5.X, (rectangle5.Y + rectangle5.Height) - 1, (rectangle5.X + rectangle5.Width) - 1, (rectangle5.Y + rectangle5.Height) - 1);
                        break;

                    case TableLayoutPanelCellBorderStyle.Outset:
                    {
                        using (Pen pen = new Pen(SystemColors.Window))
                        {
                            g.DrawLine(pen, (rectangle5.X + rectangle5.Width) - 1, rectangle5.Y, (rectangle5.X + rectangle5.Width) - 1, (rectangle5.Y + rectangle5.Height) - 1);
                            g.DrawLine(pen, rectangle5.X, (rectangle5.Y + rectangle5.Height) - 1, (rectangle5.X + rectangle5.Width) - 1, (rectangle5.Y + rectangle5.Height) - 1);
                            break;
                        }
                    }

                    default:
                        ControlPaint.PaintTableCellBorder(cellBorderStyle, g, rectangle5);
                        break;
                    }
                    ControlPaint.PaintTableControlBorder(cellBorderStyle, g, displayRectangle);
                }
            }
        }
        /// <include file='doc\TableLayoutPanel.uex' path='docs/doc[@for="TableLayoutPanel.OnPaint"]/*' />
        protected override void OnPaintBackground(PaintEventArgs e)
        {
            base.OnPaintBackground(e);



            // paint borderstyles on top of the background image in WM_ERASEBKGND

            int cellBorderWidth = this.CellBorderWidth;

            TableLayout.ContainerInfo       containerInfo   = TableLayout.GetContainerInfo(this);
            TableLayout.Strip[]             colStrips       = containerInfo.Columns;
            TableLayout.Strip[]             rowStrips       = containerInfo.Rows;
            TableLayoutPanelCellBorderStyle cellBorderStyle = this.CellBorderStyle;



            if (colStrips == null || rowStrips == null)
            {
                return;
            }
            int cols = colStrips.Length;
            int rows = rowStrips.Length;

            int totalColumnWidths = 0, totalColumnHeights = 0;

            Graphics  g           = e.Graphics;
            Rectangle displayRect = DisplayRectangle;
            Rectangle clipRect    = e.ClipRectangle;

            //leave the space for the border
            int  startx;
            bool isRTL = (RightToLeft == RightToLeft.Yes);

            if (isRTL)
            {
                startx = displayRect.Right - (cellBorderWidth / 2);
            }
            else
            {
                startx = displayRect.X + (cellBorderWidth / 2);
            }

            for (int i = 0; i < cols; i++)
            {
                int starty = displayRect.Y + (cellBorderWidth / 2);

                if (isRTL)
                {
                    startx -= colStrips[i].MinSize;
                }

                for (int j = 0; j < rows; j++)
                {
                    Rectangle outsideCellBounds = new Rectangle(startx, starty, ((TableLayout.Strip)colStrips[i]).MinSize, ((TableLayout.Strip)rowStrips[j]).MinSize);

                    Rectangle insideCellBounds = new Rectangle(outsideCellBounds.X + (cellBorderWidth + 1) / 2, outsideCellBounds.Y + (cellBorderWidth + 1) / 2, outsideCellBounds.Width - (cellBorderWidth + 1) / 2, outsideCellBounds.Height - (cellBorderWidth + 1) / 2);

                    if (clipRect.IntersectsWith(insideCellBounds))
                    {
                        //first, call user's painting code
                        using (TableLayoutCellPaintEventArgs pcea = new TableLayoutCellPaintEventArgs(g, clipRect, insideCellBounds, i, j)) {
                            OnCellPaint(pcea);
                        }
                        // paint the table border on top.
                        ControlPaint.PaintTableCellBorder(cellBorderStyle, g, outsideCellBounds);
                    }
                    starty += rowStrips[j].MinSize;
                    // Only sum this up once...
                    if (i == 0)
                    {
                        totalColumnHeights += rowStrips[j].MinSize;
                    }
                }

                if (!isRTL)
                {
                    startx += colStrips[i].MinSize;
                }
                totalColumnWidths += colStrips[i].MinSize;
            }


            if (!HScroll && !VScroll && cellBorderStyle != TableLayoutPanelCellBorderStyle.None)
            {
                Rectangle tableBounds = new Rectangle(cellBorderWidth / 2 + displayRect.X, cellBorderWidth / 2 + displayRect.Y, displayRect.Width - cellBorderWidth, displayRect.Height - cellBorderWidth);
                // paint the border of the table if we are not auto scrolling.
                // if the borderStyle is Inset or Outset, we can only paint the lower bottom half since otherwise we will have 1 pixel loss at the border.
                if (cellBorderStyle == TableLayoutPanelCellBorderStyle.Inset)
                {
                    g.DrawLine(SystemPens.ControlDark, tableBounds.Right, tableBounds.Y, tableBounds.Right, tableBounds.Bottom);
                    g.DrawLine(SystemPens.ControlDark, tableBounds.X, tableBounds.Y + tableBounds.Height - 1, tableBounds.X + tableBounds.Width - 1, tableBounds.Y + tableBounds.Height - 1);
                }
                else if (cellBorderStyle == TableLayoutPanelCellBorderStyle.Outset)
                {
                    using (Pen pen = new Pen(SystemColors.Window)) {
                        g.DrawLine(pen, tableBounds.X + tableBounds.Width - 1, tableBounds.Y, tableBounds.X + tableBounds.Width - 1, tableBounds.Y + tableBounds.Height - 1);
                        g.DrawLine(pen, tableBounds.X, tableBounds.Y + tableBounds.Height - 1, tableBounds.X + tableBounds.Width - 1, tableBounds.Y + tableBounds.Height - 1);
                    }
                }
                else
                {
                    ControlPaint.PaintTableCellBorder(cellBorderStyle, g, tableBounds);
                }
                ControlPaint.PaintTableControlBorder(cellBorderStyle, g, displayRect);
            }
            else
            {
                ControlPaint.PaintTableControlBorder(cellBorderStyle, g, displayRect);
            }
        }