private void Delete(object sender, EventArgs e) { if (((MainForm)this.MdiParent).ActiveMdiChild == this) { if (MessageBox.Show("라인을 삭제 하시겠습니까?", "", MessageBoxButtons.YesNo) == DialogResult.No) { return; } try { dgvLinelist.EndEdit(); List <int> CheckList = new List <int>(); foreach (DataGridViewRow row in dgvLinelist.Rows) { DataGridViewCheckBoxCell chk = (DataGridViewCheckBoxCell)dgvLinelist[0, row.Index]; if (chk.Value == null) { continue; } else if ((bool)chk.Value == true) { CheckList.Add(dgvLinelist[3, row.Index].Value.ToInt()); } } int line_id = Convert.ToInt32(dgvLinelist.SelectedRows[0].Cells[3].Value); if (CheckList.Count > 0) { service.LineDelete(CheckList); LoadData(); } else { MessageBox.Show("다시 선택해주세요"); } } catch (Exception err) { MessageBox.Show(err.Message); } } }