title: Changing a datagridview row color at runtime
body: <p>I'm inheriting the DataGridView control for a control I'm developing.
  My goal is to make each row color representing an object State that can change at runtime.
  My object implements the Observable design pattern.
  So I decided to develop my own DataGridViewRow class, implementing the Observer pattern and making my row observe the object.
  In this class, I have this method :</p>
  
  <pre><code>public void UpdateColors(int state)
  {
      DefaultCellStyle.BackColor = m_ETBackColors[state];
      DefaultCellStyle.ForeColor = m_ETForeColors[state];
  }
  </code></pre>
  
  <p>I can't observe my object for the moment, so, to test the color changing, I call my UpdateColors method upon selected rows on the SelectionChanged event.</p>
  
  <p>And now is the moment it doesn't work!
  My previously selected rows stay blue (like when they were selected), cells texts are layered when I scroll.
  I tried calling DataGridView.Refresh(), but that doesn't work either.</p>
  
  <p>I must add my datagridview is not bound to a datasource : I don't know how many columns I have before runtime, so I feed it by hand.</p>
  
  <p>Can anyone say me what I'm doing wrong?</p>
  
  <p>========== Update ==========</p>
  
  <p>This works :</p>
  
  <pre><code>public void UpdateColors(int state)
  {
      DefaultCellStyle.BackColor = System.Drawing.Color.Yellow;
      DefaultCellStyle.ForeColor = System.Drawing.Color.Black;
  }
  </code></pre>
  
  <p>But this doesn't work :</p>
  
  <pre><code>public void UpdateColors(int state)
  {
      DefaultCellStyle.BackColor = m_ETBackColors[nEtattech];
      DefaultCellStyle.ForeColor = m_ETForeColors[nEtattech];
  }
  </code></pre>
  
  <p>with :</p>
  
  <pre><code>    System.Drawing.Color[] m_ETBackColors = new System.Drawing.Color[] { };
      System.Drawing.Color[] m_ETForeColors = new System.Drawing.Color[] { };
  </code></pre>
  
  <p>There is no array overflow : they are constructor parameters.</p>