我在 C# winforms 4.0 中有一个 datagridview。我正在对背景颜色和边框进行一些自定义单元格绘画。这是我在 CellPainting 事件中的代码:
//Background color
if (e.RowIndex / 3 % 2 == 0 && e.RowIndex > -1)
e.CellStyle.BackColor = Color.LightGray;
//Bottom border
if (e.RowIndex % 3 == 2)
{
using (Pen p = new Pen(Brushes.Black))
{
p.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
e.Graphics.DrawLine(p, new Point(0, e.CellBounds.Bottom - 1),
new Point(e.CellBounds.Right, e.CellBounds.Bottom - 1) );
}
e.PaintContent(e.CellBounds);
}
这就是我的datagridview的样子(我不能发布图片,所以这里有一个链接) http://i.imgur.com/hLR3JjV.png
如您所见,背景颜色在我的所有单元格中都有效,但是对于仅部分显示在 datagridview 中的单元格,边框没有绘制。例如,我的图像是 Column4 中每一行的单元格
有人可以帮我弄清楚我能做些什么来让部分显示的单元格绘制底部边框吗?