To have dot style or other style gridlines, you can handle the CellPainting event to custom paint the cells
Code Snippet
dataGridView1_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e)
{
e.PaintParts &= ~DataGridViewPaintParts.Border;
}
void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
if (e.ColumnIndex > -1 && e.RowIndex > -1)
{
e.Paint(e.CellBounds, DataGridViewPaintParts.All & ~DataGridViewPaintParts.Border);
Pen pen = new Pen(this.dataGridView1.GridColor);
pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
//draw bottom border side
e.Graphics.DrawLine(pen, e.CellBounds.Left, e.CellBounds.Bottom - 1,
e.CellBounds.Right, e.CellBounds.Bottom - 1);
//draw right border side
e.Graphics.DrawLine(pen, e.CellBounds.Right - 1, e.CellBounds.Top,
e.CellBounds.Right - 1, e.CellBounds.Bottom);
e.Handled = true;
}
}
GridColor will change the color of the grid lines. I can't think of a way to change the pen type. I did however find a CellBorderStyle and DataGridViewAdvancedBorderStyle properties that let you change the styles.
|