//delete family history private void button3_Click(object sender, EventArgs e) { ConnectDB EMRDatabase = new ConnectDB(); for (int i = 0; i < FMHCB_Relationship.Count(); i++) { EMRDatabase.RemoveFamilyMedHistory(PatientInfo[2], FMHCB_Relationship[i], FMHCB_Condition[i], FMHCB_Age[i]); } List <DataGridViewRow> toDelete = new List <DataGridViewRow>(); foreach (DataGridViewRow row in dataGridView3.Rows) { DataGridViewCheckBoxCell cell = row.Cells[3] as DataGridViewCheckBoxCell; if ((bool)cell.EditedFormattedValue == true) { toDelete.Add(row); } } foreach (DataGridViewRow row in toDelete) { dataGridView3.Rows.Remove(row); } dataGridView3.ClearSelection(); button3.Enabled = false; }