I'm trying to draw my own grid lines because I want thicker lines than the default data grid view lines. This is the code I'm using to do it:
private void dgv_Wafer_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
using (Pen p = new Pen(Brushes.Black, 12))
{
e.Graphics.DrawLine(p, new Point(0, 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, 0), new Point(e.CellBounds.Right - 1, e.CellBounds.Bottom));
}
}
The lines are drawn but the horizontal lines won't be drawn in the last column and the vertical lines won't be drawn in the last row. The lines are creating a grid that is a column and row too small. Does anyone know how to fix this?
See Question&Answers more detail:os