title: Show message box when the check box in the datagridview is checked
body: <p>I have a database like this (view on <code>DataGridView</code>):</p>
  
  <p><img src="https://i.stack.imgur.com/tKbNC.png" alt="enter image description here"></p>
  
  <p>As you can see on the image above, there are checkboxes in the <code>DataGridView</code>. I want when the checkbox is checked, the messagebox show a some text.</p>
  
  <p>How can I achieve that?</p>
  
  <p>What I have tried is whenever I checked the checkbox, the messagebox never appear and the first row of January 2014 column is checked when I run the program, but when I uncheck and check again, the messagebox not appearing.</p>
  
  <p>Here is the code that I am using:</p>
  
  <pre><code>private void Amount(object sender, DataGridViewCellEventArgs e)
          {
              DataTable _dt = (DataTable)dataGridView1.DataSource;
  
              foreach(DataGridViewRow _row in _dt.Rows)
              {
                  if (Convert.ToBoolean(_row.Cells["4"].Value) == true)
                  {
                      MessageBox.Show("Checked");
                  }
              }
  
          }
  </code></pre>
  
  <p>And I called it in:</p>
  
  <pre><code>dataGridView1.CellValueChanged += new DataGridViewCellEventHandler(this.Amount);
  </code></pre>
  
  <p>I added the checkboxes by manually through database, here is my access database looks like:</p>
  
  <p><img src="https://i.stack.imgur.com/2GNyi.png" alt="enter image description here"></p>
  
  <p>Your answer much appreciated! Thank you!</p>
  
  <p><strong><em>UPDATE:</em></strong></p>
  
  <p>The code below is the code from Sir Daniloloko that I have modified, I used the <code>List&lt;int&gt;</code>, because the ColumnIndex that I want to check is more than 1:</p>
  
  <pre><code>dataGridView1.CellValueChanged += new DataGridViewCellEventHandler(this.Amount);
  
  List&lt;int&gt; _columnIndexes;
  
  private void dataGridView1_CurrentCellDirtyStateChanged(object sender, EventArgs e)
          {
              if (dataGridView1.IsCurrentCellDirty)
              {
                  dataGridView1.CommitEdit(DataGridViewDataErrorContexts.Commit);
              }
          }
  
  private void Amount(object sender, DataGridViewCellEventArgs e)
          {
              _columnIndexes = new List&lt;int&gt;(new int[] { 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 });
  
              foreach (int index in _columnIndexes)
              {
                  if (e.ColumnIndex == index)
                  {
                      var value = ((DataGridView)sender).Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
  
                      if (value != null)
                      {
                          if (Convert.ToBoolean(value) == true)
                          {
                              MessageBox.Show("Checked. \n" + "Column Number: " + e.ColumnIndex + "", "Checked");
                          }
  
                          else
                          {
                              MessageBox.Show("Not Checked. \n" + "Column Number: " + e.ColumnIndex + "", "Not Checked");
                          }
                      }
                  }
              }
          }
  </code></pre>
  
  <p>But from the code above, still the <code>MessageBox.Show("Not Checked");</code> or <code>MessageBox.Show("Checked");</code> is not showing whenever I checked or unchecked the CheckBox(es) in the <code>DataGridView</code> (On the runtime). What I want is the <code>MessageBox</code> is show whenever right after I checked or unchecked the CheckBox(es), not when I hit <code>Enter</code> or <code>Update</code> button then the <code>MessageBox</code> is shows (depending my checkbox(es) is unchecked or checked)</p>
  
  <p>Thank you very much!</p>
  
  <p>Sorry for confusing you guys more.</p>
  
  <p><strong><em>Solved:</em></strong></p>
  
  <p>I forgot to declared the <code>dataGridView1.CurrentCellDirtyStateChanged += new EventHandler(this.DirtyStateChanged);</code> in the <code>Form_Load</code>.</p>
  
  <p>Thank you very much and sorry for confusing you guys.</p>
  
  <p>Regards.</p>