DGV多行选择
//对每项进行删除 for (int i = 0; i < dgvYuanGong.Rows.Count; i++) { if ((bool)dgvYuanGong.Rows[i].Cells["xd"].EditedFormattedValue == true) { myXiTong_YuanGongXinXi.YuanGongID = int.Parse(dgvYuanGong.Rows[i].Cells["YuanGongID"].Value.ToString().Trim()); BLL_RenLiZiYuan.YuanGongXinXi.DeleteYuanGongXinXi(myXiTong_YuanGongXinXi); } }
if (MessageBox.Show("确定删除这 " + dgv_HeTong_YuanGong.SelectedRows.Count.ToString() + " 条数据?", "温馨提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK) { Cursor.Current = Cursors.WaitCursor; //循环删除选中数据 for (int i = dgv_HeTong_YuanGong.SelectedRows.Count; i > 0; i--) { try { MyRLZY_HeTong_YuanGong = new Model.RLZY_HeTong_YuanGong(); MyRLZY_HeTong_YuanGong.YuanGongHeTongID = Convert.ToInt32(dgv_HeTong_YuanGong.SelectedRows[0].Cells["YuanGongHeTongID"].Value.ToString().Trim()); BLL_RenLiZiYuan.HeTongGuanLi.Delete_YuanGongHeTong(MyRLZY_HeTong_YuanGong); dgv_HeTong_YuanGong.Rows.Remove(dgv_HeTong_YuanGong.SelectedRows[0]); } catch { } } Cursor.Current = Cursors.Default;