title: Changing color of a Checkbox of a DataGridCheckBoxCell C# Winform
body: <p>I have asked this question some time ago <a href="https://stackoverflow.com/questions/14124033/hide-some-datagridview-checkbox-cell">Hide some datagridview checkbox cell</a>. I couldn´t get a good answer, so I decided to try something different.</p>
  
  <p>I have a grid with all the installments of a loan. Every installment has a checkbox. When that checkbox is checked, I´m indicating that the client is paying for that one.</p>
  
  <p>Now, when a installment is already paid, the checkbox is not needed. Right now, I disabled the checkbox for payed installments. It´s visible, but when clicked it does nothing. But i wanted to do is to paint the checkbox in green. Like in this image (the color was painted in Paint, its not a real image)</p>
  
  <p><img src="https://i.stack.imgur.com/ZeQR7.png" alt="enter image description here"></p>
  
  <p>Ok, I have tried to hide the checkbox before using this code:</p>
  
  <pre><code>private void dgv_Cuotas_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
      {           
          if (e.RowIndex &gt;= 0 &amp;&amp; e.ColumnIndex &gt;= 0)
          {
              if (dgv_Cuotas.Columns[e.ColumnIndex].Name == "Seleccionar" &amp;&amp; Convert.ToBoolean(dgv_Cuotas.Rows[e.RowIndex].Cells["pagada"].Value) == true)
              {
                  e.CellStyle.BackColor = Color.Green;
                  e.PaintBackground(e.ClipBounds, true);
                  e.Handled = true;
              }
          }
      }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/izP37.png" alt="enter image description here"></p>
  
  <p>With this I paint the whole cell, but I just want to paint the checkbox. Also, with this implementation, when I click that cell, I can notice I´m clicking a checkbox, and the background color turns white, like this:</p>
  
  <p><img src="https://i.stack.imgur.com/hsoxY.png" alt="enter image description here"></p>
  
  <p>I´m creating the DataGridView (dgv_Cuotas) Rows and Columns by assingning Datasource = lista_cuota (List of installments) during runtime. Thats why the checkbox column is added after it by code:</p>
  
  <pre><code>DataGridViewCheckBoxColumn chbox = new DataGridViewCheckBoxColumn();
          {
              chbox.CellTemplate = new DataGridViewCheckBoxCell();
              chbox.HeaderText = "";
              chbox.Name = "Seleccionar";
              chbox.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;
              chbox.FlatStyle = FlatStyle.Standard;
          }
          dgv_Cuotas.Columns.Insert(16, chbox);
          dgv_Cuotas.Columns[16].DisplayIndex = 0;
  </code></pre>
  
  <p>Doing it this way, I cant "hide" the checkbox cell assigning a DataGridViewTextBoxCell to a specific cell, so I wanted to try painting just the checkbox instead. </p>
  
  <p>As I´m using Entity framework, I don´t want to add new fields to the class.</p>