コード例 #1
0
        public void OnPaint(RowPaintArgs e)
        {
            if (GridView == null || GridView.HeaderRow == null)
            {
                return;
            }

            if (HasLeftExpander)
            {
                // paint background
                using (Brush brush = new SolidBrush(BackColor))
                {
                    e.Graphics.FillRectangle(brush, e.Rectangle);
                }

                if (BorderPen != null)
                {
                    e.Graphics.DrawRectangle(BorderPen, e.Rectangle);
                }

                Image im = Expanded ? ExpandedImage : ShrunkenImage;
                e.Graphics.DrawImage(im, e.Rectangle.X + im.Width, e.Rectangle.Y + im.Height, im.Width, im.Height);
            }

            // paint this row
            int totalHeight = RowHeight;
            int left        = e.Rectangle.Left + LeftOffset;
            int top         = e.Rectangle.Top;

            foreach (string col in GridView.HeaderRow.Columns)
            {
                GridItemBase item      = GetItem(col);
                int          itemwidth = GridView.GetColumnWidth(col, ItemColumnSpan(item, col));

                if (left >= e.ClipRectangle.Left - itemwidth && left <= e.ClipRectangle.Right + itemwidth)
                {
                    item.OnPaint(new ItemPaintArgs(e.Graphics, new Rectangle(left, top, itemwidth, totalHeight),
                                                   Selected ? ItemState.Selected : ItemState.Normal));
                }

                left += GridView.GetColumnWidth(col, 1);
            }

            // paint subrows
            if (HasVisibleChildren)
            {
                top += RowHeight + RowSeparation;

                foreach (GridRow row in Rows)
                {
                    int rowheight = row.RowAndChildrenHeight;
                    if (top >= e.ClipRectangle.Top - rowheight && top <= e.ClipRectangle.Bottom + rowheight)
                    {
                        row.OnPaint(new RowPaintArgs(e.Graphics, e.ClipRectangle, new Rectangle(e.Rectangle.Left, top, e.Rectangle.Width, rowheight)));
                    }
                    top += rowheight + row.SpaceAfter;
                }
            }
        }