Исправь ошибку System.NullReferenceException: "Ссылка на объект не указывает на…
- User
Исправь ошибку System.NullReferenceException: "Ссылка на объект не указывает на экземпляр объекта."
System.Windows.Forms.DataGridViewCell.Value.get вернул null. Car car = new Car(); var resultdoc = car.GetExpiredRecords(); var resulteq = car.GetExpiredEquip();
List<string> expiredDocIds = resultdoc.ExpiredIds; List<string> expiredEqIds = resulteq.ExpiredIds; // Обновляем цвет строк в dataGridView1 for (int i = 0; i < dataGridView1.Rows.Count; i++) { string carId = dataGridView1.Rows[i].Cells[0].Value.ToString(); if (expiredDocIds.Contains(carId) || expiredEqIds.Contains(carId)) { dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.Red; } else { dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.White; } } int countdoc = resultdoc.ExpiredCount; int counteq = resulteq.ExpiredCount; if (countdoc > 0) { string message = $"Количество машин с просроченными документами: {countdoc}\n" + $"Номера машин с просроченными документами:\n{string.Join("\n", resultdoc.ExpiredIds)}"; MessageBox.Show(message, "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning); } if (counteq > 0) { string message = $"Количество машин с просроченным оборудованием: {counteq}\n" + $"Номера машин с просроченным оборудованием:\n{string.Join("\n", resulteq.ExpiredIds)}"; MessageBox.Show(message, "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning); }
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.