I have the following code:
using (Pen gridPen = new Pen(Color.Black, 1))
{
if ((e.RowIndex % 4) == 0)
{
e.Graphics.DrawLine(gridPen, e.CellBounds.X, e.CellBounds.Top-1, e.CellBounds.Right-1, e.CellBounds.Top-1);
}
}
This does draw the grid lines on the datagridview every 4 rows (as required), but when I scroll on the datagridview the lines disappear, then sometimes re-appear again. Anybody know why? Thanks.
I didn't test it, Try to call Invalidate
method for the DataGrid in Scroll
event handler.
Good luck!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.