foreach (var dr in dgvOdExec.Grid.Rows) { if (dr.Cells[nameof(MedicalSkillsVo.OdTypCode)].Text == ExtraCharacterStrDefine.TREAT) { dr.Cells[nameof(MedicalSkillsVo.ExecCnt)].Appearance.BackColor = Color.FromArgb(0, 255, 255); dr.Activation = Activation.AllowEdit; } else { dr.Activation = Activation.NoEdit; } }