Use the Datagridview CellPainting event. Just copy this code there.
if (e.RowIndex == -1)
{
SolidBrush br= new SolidBrush(Color.Blue);
e.Graphics.FillRectangle(br, e.CellBounds);
e.PaintContent(e.ClipBounds);
e.Handled = true;
}
else
{
SolidBrush br= new SolidBrush(Color.Orange);
e.Graphics.FillRectangle(br, e.CellBounds);
e.PaintContent(e.ClipBounds);
e.Handled = true;
}
The if checks if its a Header or not. Use the colors you want.. If you don´t want to paint the header just erase all the code inside the if.
I you want a gradient backcolor tell me..
EDIT:
Here is a code to paint pair rows in one color and impairs in another. You must use the Cellpainting event too..
else
{
if (e.RowIndex % 2 == 0)
{
SolidBrush br = new SolidBrush(Color.Gainsboro);
e.Graphics.FillRectangle(br, e.CellBounds);
e.PaintContent(e.ClipBounds);
e.Handled = true;
}
else
{
SolidBrush br = new SolidBrush(Color.White);
e.Graphics.FillRectangle(br, e.CellBounds);
e.PaintContent(e.ClipBounds);
e.Handled = true;
}
}
EDIT 2: Where the cellpainting event is?