title: Datagridview Cell Backcolor formatting
body: <pre><code> foreach (DataGridViewRow row in dataGridView1.Rows)
              {
                  string kesim = Convert.ToString(row.Cells["kesim"].Value);
  
                  if (kesim == "True")
                  {
  
  
                      dataGridView1.Rows[row.Index].Cells["kesim"].Style.BackColor = Color.Green;
                      dataGridView1.Rows[row.Index].Cells["kesim"].ReadOnly = true;
                      dataGridView1["kesim", row.Index].ReadOnly = true;
                      dataGridView1["kesim", row.Index].Style.BackColor = Color.Green;          
                   }
                 else
                  {
  
                      dataGridView1.Rows[row.Index].Cells["kesim"].Style.BackColor = Color.Red;
                      dataGridView1.Rows[row.Index].Cells["kesim"].ReadOnly = true;
                      dataGridView1["kesim", row.Index].ReadOnly = true;
                      dataGridView1["kesim", row.Index].Style.BackColor = Color.Red;      
                  }
                  string torna = Convert.ToString(row.Cells["torna"].Value);
  
                  if (torna == "True")
                  {
  
  
                      dataGridView1.Rows[row.Index].Cells["torna"].Style.BackColor = Color.Green;
                      dataGridView1.Rows[row.Index].Cells["torna"].ReadOnly = true;
                      dataGridView1["torna", row.Index].ReadOnly = true;
                      dataGridView1["torna", row.Index].Style.BackColor = Color.Green;
                  }
                else
                  {
  
  
                      dataGridView1.Rows[row.Index].Cells["torna"].Style.BackColor = Color.Red;
                      dataGridView1.Rows[row.Index].Cells["torna"].ReadOnly = true;
                      dataGridView1["torna", row.Index].ReadOnly = true;
                      dataGridView1["torna", row.Index].Style.BackColor = Color.Red;
                  }
              }
  </code></pre>
  
  <p>My first row  ;</p>
  
  <p><a href="http://prntscr.com/4csw89" rel="nofollow noreferrer">http://prntscr.com/4csw89</a></p>
  
  <p>My second row ; </p>
  
  <p><a href="http://prntscr.com/4cswco" rel="nofollow noreferrer">http://prntscr.com/4cswco</a></p>
  
  <p>i want to if the cell value is true i want to change the back color to green else red.</p>
  
  <p>I took the code from this link ; </p>
  
  <p><a href="https://stackoverflow.com/questions/13502071/using-a-dynamic-list-of-custom-object-and-cant-dynamically-change-datagrids-ce">Using a dynamic list of Custom Object and can&#39;t dynamically change dataGrid&#39;s cells properties</a></p>
  
  <p>Please help my question</p>