Try setting the e.Handled = true;
to control the painting. Add back in the default painting of the cells:
e.PaintBackground(e.ClipBounds, true);
e.PaintContent(e.ClipBounds);
using (Pen p = new Pen(Brushes.Black, 12)) {
e.Graphics.DrawLine(p, new Point(e.CellBounds.Left, e.CellBounds.Bottom),
new Point(e.CellBounds.Right, e.CellBounds.Bottom));
}
using (Pen p = new Pen(Brushes.Black, 6)) {
e.Graphics.DrawLine(p, new Point(e.CellBounds.Right, e.CellBounds.Top),
new Point(e.CellBounds.Right, e.CellBounds.Bottom));
}
e.Handled = true;
Your code was also using 0 for left and top, but the CellBounds values are based on the control's interior space, so you should use e.CellBounds.Left
and e.CellBounds.Top
You might want to adjust the points of your line to account for the thickness of those borders, they are bleeding outside of the cell at the moment.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…