title: Changing style of certain cells in DataGridView
body: <p>I'm trying to change the color of certain cells in a DataGridView depending on wether the value is the same as in other cells. Sadly though, it's not working. This is the code which I thought should work:</p>
  
  <pre><code>for (int i = 0; i &lt; dataGridView2.Rows.Count; i++)
  {
      for (int j = 1; j &lt; 8; j++)
          for (int k = 8; k &lt; 20; k++)
              if (dataGridView2.Rows[i].Cells[j].Value == dataGridView2.Rows[i].Cells[k].Value)
                  dataGridView2.Rows[i].Cells[j].Style.BackColor = Color.Green;
  }
  dataGridView2.Refresh();
  </code></pre>
  
  <p>All columns are created with typeof(int) so it shouldn't be a type problem. Also debugging showed my program does enter the if-clause, yet still it doesn't display the changes.</p>
  
  <p>Thanks in advance for any help.</p>