Change Color of Alternate Rows in the DataGridView

Change Color of Alternate Rows in the DataGridView
C#


private void btnAlternate_Click(object sender, EventArgs e)
{
this.dgv.RowsDefaultCellStyle.BackColor = Color.White;
this.dgv.AlternatingRowsDefaultCellStyle.BackColor = Color.Aquamarine;
}


VB.NET

Private Sub btnAlternate_Click(ByVal sender As Object, ByVal e As EventArgs)

Me.dgv.RowsDefaultCellStyle.BackColor = Color.White
Me.dgv.AlternatingRowsDefaultCellStyle.BackColor = Color.Aquamarine

End Sub


Comments

Guest Author: suseelan28 Mar 2013

Thanks code is helpful

Guest Author: suseelan28 Mar 2013

Thanks Code is helpful



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: