Hello Friend,

i hope someone can help me to solve my problem, i already put my database on datagridview, but my boss dont want it in standard color, so now i dont now how to change it, can i change the color using datagridview or i need to use another tools like listview?

Try using the BackgroundColor property. Or something like this : Mygrid.Rows(RowIndex).DefaultCellStyle.BackColor = Color.Mycolor

Try :

    For i As Integer = 0 To DataGridView1.RowCount - 1
        If DataGridView1.Rows(i).Index Mod 2 = 0 Then
            DataGridView1.Rows(i).DefaultCellStyle.BackColor = Color.LightBlue
        Else
            DataGridView1.Rows(i).DefaultCellStyle.BackColor = Color.LemonChiffon
        End If
    Next i

Edited 3 Years Ago by Jx_Man

Comments
That works, but why not use AlternatingRowsDefaultCellStyle?

As TnTinMN suggested. You can try AlternatingRowsDefaultCellStyle. The value for alternating rows overrides the value for all rows.

Just two lines code :

    DataGridView1.RowsDefaultCellStyle.BackColor = Color.LightBlue  'Or you can use: DataGridView1.DefaultCellStyle.BackColor = Color.LightBlue
    DataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.LemonChiffon

Edited 3 Years Ago by Jx_Man

Comments
Great example
This question has already been answered. Start a new discussion instead.