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?

Recommended Answers

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 …
Jump to Post

All 4 Replies

Re: Datagridview row color 80 80

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

Re: Datagridview row color 80 80

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
commented: That works, but why not use AlternatingRowsDefaultCellStyle? +8
Re: Datagridview row color 80 80

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
commented: Great example +4
Re: Datagridview row color 80 80

Thanks Jx Man!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.