private void btnQuitar_Click(object sender, EventArgs e) { try { if (renglon1.Count > 0) { if (MessageBox.Show(this, "Desea eliminar este renglón?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { foreach (var item in renglon1) { var J = grddatos1.CurrentRow.Cells[7].Value; using (var context = new Profit_RGEntities()) { renglon1.RemoveAt(grddatos1.CurrentCell.RowIndex); context.pGIT_Asign_EquipoEliminar(Guid.Parse(J.ToString())); grddatos1.DataSource = ""; grddatos1.DataSource = renglon1; grddatos1.CurrentCell = grddatos1[0, renglon1.Count - 1]; } CargarAsignaciones(); } } } } catch (Exception ex1) { MessageBox.Show(this, "Su registro ha sido eliminado satisfactoriamente.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); } }