title: Delete multiple rows in a DataGridView(table)
body: <p>I have a datable "myTable", which is bind with a DataGridView "dgv". The DataGridView "dgv" has a checkbox column. My goal is to delete rows checked in a button event. The datatable is updated of course.
  Now my code is only working for deleting one row not for multiple rows.</p>
  
  <p>Thanks for help.</p>
  
  <pre><code> private void btnDel_Click(object sender, EventArgs e)
      {
          try
          {
              if (dgv.RowCount&gt;0)
              {
                  foreach (DataGridViewRow row in dgv.Rows)
                  {
                      DataGridViewCheckBoxCell check = row.Cells[0] as DataGridViewCheckBoxCell;
                      if (check.Value != null)
                      {
                          if ((bool)check.Value)
                          {
                              DataRowView currentDataRowView = (DataRowView)dgv.CurrentRow.DataBoundItem;
                              DataRow dataRow = currentDataRowView.Row;
  
                              int n = dgv.CurrentRow.Index;
                              int intID = Convert.ToInt32(dgv.Rows[n].Cells[0].Value);
                              myTable.Rows.Remove(dataRow);
                              dgv.DataSource = myTable;
  
                              Int32 intVal = Convert.ToInt32(row.Cells[1].Value);
                              if (intVal == intID)
                              {
                                  check.Value = null;
                              }
                          }
                      }
                  }
              }
          }
          catch (Exception ex)
          {
              MessageBox.Show(ex.Message);
          }
      }
  </code></pre>