Bonjour, jeux colorer les ligne dont le nom de la collone est Alerte, mais ça marche pas, jai fais comme suite
y'a cette exception : La référence d'objet n'est pas définie à une instance d'un objet. au niveau de la ligne : if ((currentRow.Cells["Alerte"].Value.ToString()) == "Avant 15 jours").
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32 foreach (DataGridViewColumn col in dgv.Columns) { col.SortMode = DataGridViewColumnSortMode.Automatic; col.ReadOnly = true; dgv.RowHeadersVisible = true; foreach (DataGridViewRow row in dgv.Rows) { if (boo == -1) { row.DefaultCellStyle.BackColor = Color.LightGray; boo = 1; } else if (boo == 1) { row.DefaultCellStyle.BackColor = Color.White; boo = -1; } } } foreach (DataGridViewRow currentRow in dgv.Rows) { if ((currentRow.Cells["Alerte"].Value.ToString()) == "Avant 15 jours") { currentRow.DefaultCellStyle.ForeColor = Color.Green; } else if ((currentRow.Cells["Etat"].Value.ToString()) == "Désactivé") { currentRow.DefaultCellStyle.ForeColor = Color.Red; } }
Merci infiniment.
Partager