private void dgrid_CellEndEdit(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 6) { if (!string.IsNullOrWhiteSpace(dgrid.CurrentCell.Value?.ToString())) { var townId = (Town)Enum.Parse(typeof(Town), dgrid.CurrentCell.Value?.ToString()); dgrid.CurrentRow.Cells[7].Value = PostalCodes.FirstOrDefault(x => x.Key == (int)townId).Value; } } if (!validateGrid(e.RowIndex)) { dgrid.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.Red; return; } var addCommand = AddtoPersonCommand(e.RowIndex); dgrid.Rows[e.RowIndex].Cells[10].Value = addCommand.Age; if (addCommand.IsValid) { dgrid.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.White; EnableButtons(); } }