Click here to Skip to main content
15,921,622 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How do I change Backcolor of Datagrindview with MySQL-Data.


Thats the normal way.

dataGridView.Rows[rowIndex].Cells[columnIndex].Style.BackColor = Color.Red;



But i want to Change the Color if the table has updated data.

Number 1 = green
Number 2 = yellow


and all in the same cell only with the MySQL-Data



Can somebody help me ?

What I have tried:

How do I change Backcolor of Datagrindview with MySQL-Data.


Thats the normal way.

<pre>dataGridView.Rows[rowIndex].Cells[columnIndex].Style.BackColor = Color.Red;



But i want to Change the Color if the table has updated data.

Number 1 = green
Number 2 = yellow


and all in the same cell only with the MySQL-Data



Can somebody help me ?
Posted
Updated 8-Aug-18 11:08am
Comments
[no name] 12-Jul-18 21:17pm    
You need to check the data for those column and when you bind data to grid view control you can set the cell color based on value.
Member 13904037 17-Jul-18 15:44pm    
How do i get the Right data?

1 solution

Use event CellFormatting

Dim cell As DataGridViewCell

If dataGridView.Rows(e.RowIndex).Cells(Index Cell To Compare).Value =1 Then

cell.Style.BackColor = Color.Green

Else If dataGridView.Rows(e.RowIndex).Cells(Index Cell To Compare).Value =2 Then

cell.Style.BackColor = Color.Yellow

End If
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900