Помогите исправить ошибку "Error 1 The name 'i' does not exist in the current context" - C#

Узнай цену своей работы

Формулировка задачи:

Листинг программы
  1. private void button4_Click(object sender, EventArgs e)
  2. {
  3. for (i = 0; i <= пациентыDataGridView.ColumnCount - 1; i++)
  4. {
  5. for (j = 0; j <= пациентыDataGridView.RowCount - 1; j++)
  6. {
  7. пациентыDataGridView.Item(i, j).Style.BackColor = Color.White;
  8. пациентыDataGridView.Item(i, j).Style.ForeColor = Color.Black;
  9. }
  10. }
  11. for (i = 0; i <= пациентыDataGridView.ColumnCount - 1; i++)
  12. {
  13. for (j = 0; j <= пациентыDataGridView.RowCount - 1; j++)
  14. {
  15. if (strings.InStr(пациентыDataGridView.Item(i, j).Value, textBox1.Text))
  16. {
  17. пациентыDataGridView.Item(i, j).Style.BackColor = Color.AliceBlue;
  18. пациентыDataGridView.Item(i, j).Style.ForeColor = Color.Blue;
  19. }
  20. }
  21.  
  22. }
  23. }
  24. }
  25. }

Решение задачи: «Помогите исправить ошибку "Error 1 The name 'i' does not exist in the current context"»

textual
Листинг программы
  1. private void button4_Click(object sender, EventArgs e)
  2. {
  3.     for (int i = 0; i <= пациентыDataGridView.ColumnCount - 1; i++)
  4.     {
  5.         for (int j = 0; j <= пациентыDataGridView.RowCount - 1; j++)
  6.         {
  7.             пациентыDataGridView.Item[i, j].Style.BackColor = Color.White;
  8.             пациентыDataGridView.Item[i, j].Style.ForeColor = Color.Black;
  9.         }
  10.     }
  11.     for (int i = 0; i <= пациентыDataGridView.ColumnCount - 1; i++)
  12.     {
  13.         for (int j = 0; j <= пациентыDataGridView.RowCount - 1; j++)
  14.         {
  15.             string itemValue = пациентыDataGridView.Item[i, j].Value;
  16.             if (value.Contains(textBox1.Text))
  17.             {
  18.                 пациентыDataGridView.Item[i, j].Style.BackColor = Color.AliceBlue;
  19.                 пациентыDataGridView.Item[i, j].Style.ForeColor = Color.Blue;
  20.             }
  21.         }
  22.     }
  23. }

ИИ поможет Вам:


  • решить любую задачу по программированию
  • объяснить код
  • расставить комментарии в коде
  • и т.д
Попробуйте бесплатно

Оцени полезность:

14   голосов , оценка 3.857 из 5

Нужна аналогичная работа?

Оформи быстрый заказ и узнай стоимость

Бесплатно
Оформите заказ и авторы начнут откликаться уже через 10 минут
Похожие ответы