How can double underline cell in DataGridView
similar to this image?
I want to show total in last row, and total\'s cell in DataGridView
should be
You can handle CellPainting
event of DataGridView
and draw a double border at bottom of the specified row this way:
void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
if (e.RowIndex == 1 && e.ColumnIndex >= 0)
{
e.Paint(e.CellBounds, e.PaintParts);
e.Graphics.DrawLine(Pens.Black, e.CellBounds.Left,
e.CellBounds.Bottom - 2, e.CellBounds.Right, e.CellBounds.Bottom - 2);
e.Graphics.DrawLine(Pens.Black, e.CellBounds.Left,
e.CellBounds.Bottom - 4, e.CellBounds.Right, e.CellBounds.Bottom - 4);
e.Handled = true;
}
}
Also as another option you can set DividerHeight of the the specified row to a larger value:
dataGridView1.Rows[1].DividerHeight = 5;
In case if you want to set divider height for all rows, before adding rows or before setting data source, set the DividerHeight
for RowTemplate
, for example:
dataGridView1.RowTemplate.DividerHeight = 5;