title: Revert cell style changes in a datagridview control?
body: <p>My program displays a bound datagridview.  If the user makes a change to the value in any cell, the program will change the background color of that cell.  Here is the code for that:</p>
  
  <pre><code> private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
   {
      this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.BackColor = Color.PaleGoldenrod;
   }
  </code></pre>
  
  <p>My program has an 'Undo' button that basically performs a <code>dataTable.RejectChange();</code>. When the user activates the Undo button, everything changed in the datagridview will revert back to its original value.  However, the cell background color is still as if the user changed the value in the cell.</p>
  
  <p>Quite simply, I'm wondering if there is a method I can use to <em>revert</em> the cell styles (mainly, the background color) back to their original state (which is alternating gray and white)?</p>
  
  <p>I was thinking something along the lines of capturing the original default settings by using the following statement:</p>
  
  <p><code>defaultCellStyle = this.dataGridView1.DefaultCellStyle;</code></p>
  
  <p>And, when the Undo is performed, I could do something like:</p>
  
  <p><code>this.dataGridView1.DefaultCellStyle = this.defaultCellStyle;</code></p>
  
  <p>However, this didn't seem to work as the gridview still retained the coloring in the cells as if they'd been changed.</p>
  
  <p>I don't want to keep track of every changed cell just to loop through them and change the background color to default.  I was hoping that there existed a way to just take the whole datagridview and revert it to default settings.  Does anyone know how I can accomplish this?</p>