Anonim_999

Search

May 29th, 2022
1,130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.00 KB | None | 0 0
  1. if (textBox1.Text != "")
  2.             {
  3.                 for (int i = 0; i < dataGridView1.ColumnCount; i++)
  4.                 {
  5.                     for (int j = 0; j < dataGridView1.RowCount-1; j++)
  6.                     {
  7.                         dataGridView1.Rows[j].Cells[i].Style.BackColor = Color.White;
  8.                         dataGridView1.Rows[j].Cells[i].Style.ForeColor = Color.Black;
  9.                     }
  10.                 }
  11.  
  12.                 for (int i = 0; i < dataGridView1.Columns.Count; i++)
  13.                 {
  14.                     for (int j = 0; j < dataGridView1.Rows.Count-1; j++)
  15.                     {
  16.                         if (dataGridView1.Rows[j].Cells[i].Value.ToString().Contains(textBox1.Text))
  17.                         {
  18.                             dataGridView1.Rows[j].Cells[i].Style.BackColor = Color.AliceBlue;
  19.                             dataGridView1.Rows[j].Cells[i].Style.ForeColor = Color.Blue;
  20.                         }
  21.                     }
  22.                 }
  23.             }
Advertisement
Add Comment
Please, Sign In to add comment