title: Can't change datagridview cell color when using a datasource
body: <p>I've got an interesting issue. I am trying to use a datatable as a data source for a datagridview. I want to color some of the cells of the table to indicate various things, but for some reason the color will not display. So the following code shows an uncolored cell.</p>
  
  <pre><code>dataGridView1.DataSource = table;
  
  dataGridView1.Rows[0].Cells[0].Style.BackColor = Color.Yellow;
  </code></pre>
  
  <p>I can only get a color to display after the initial form load (for example setting a cell color on the OnClick event). However, if I explicitly create the rows and columns for the view as in the code below, the coloring works. </p>
  
  <pre><code>foreach (DataColumn col in table.Columns)
      dataGridView1.Columns.Add(col.ColumnName, col.ColumnName);
  
  for (int i = 0; i &lt; table.Rows.Count; i++)
  {
      var row = table.Rows[i];
      object[] values = new object[table.Columns.Count];
      for (int x = 0; x &lt; table.Columns.Count; x++)
          values[x] = row[x].ToString();
  
      dataGridView1.Rows.Add(values);
  }
  
  dataGridView1.Rows[0].Cells[0].Style.BackColor = Color.Yellow;
  </code></pre>
  
  <p>I do not want to have the code in this manner. Does anyone know what is happening here that is preventing me from coloring the cells?</p>