private void B_Save_Click(object sender, EventArgs e) { for (int i = 0; i < Count; i++) { SAV.SetApricornCount(i, (int)dgv.Rows[i].Cells[1].Value); } Origin.CopyChangesFrom(SAV); Close(); }
private void B_Save_Click(object sender, EventArgs e) { for (int i = 0; i < Count; i++) { var cells = dgv.Rows[i].Cells; var count = int.TryParse(cells[1].Value?.ToString() ?? "0", out var val) ? val : 0; SAV.SetApricornCount(i, Math.Min(byte.MaxValue, count)); } Origin.CopyChangesFrom(SAV); Close(); }