System NullReference Exception
Bonjour
Lorsque je lance le petit prog voici ce que j'ai comme message
System.NullReferenceException: La référence d'objet n'est pas définie à une instance d'un objet. ( sur la ligne : If DgContact.Rows(i).Cells("Nom").Value.ToString.Trim <> "" Then)
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| For i = 0 To DgContact.Rows.Count - 1
If DgContact.Rows(i).Cells("Nom").Value.ToString.Trim <> "" Then
ControleChamps.CheckMailAdresse(DgContact.Rows(i).Cells("EMail").Value.ToString.Trim)
DbList.items.add(UCase(DgContact.Rows(i).Cells("Nom").Value.ToString.Trim) & _
DgContact.Rows(i).Cells("EMail").Value.ToString.Trim)
End If
Next |
le datagridviewer lui est rempli manuellement , mais initialisé comme suit
Code:
1 2 3 4 5
| For i = 0 To DgContact.Rows.Count - 1
For j = 0 To DgContact.Columns.Count - 1
DgContact.Rows(i).Cells(j).Value = String.Empty
Next
Next |
Ou ais-je commit l'erreur