private void DgvConditionsCellValueChanged(object sender, DataGridViewCellEventArgs e) { var row = dgvConditions.Rows[e.RowIndex]; if (row.IsNewRow) { dgvConditions[e.ColumnIndex, e.RowIndex].ErrorText = "Значение изменено и не сохранено"; } if (e.ColumnIndex != 0 || !row.Cells["Field"].Selected || row.Selected || row.Cells["Field"].Value == null) { return; } row.Cells["Expression"].ReadOnly = false; var fields = (string)row.Cells["Field"].Value; var obj = fields.Split('/'); var field = mainCollectionOfAllFields.Find(t => t.DisplayedName == obj[0] && t.CategoryName == obj[1]); if ((Field)row.Cells["Expression"].Tag == field) { return; } row.Cells["Expression"] = ChooseRightCellType(field); if (row.Cells["Expression"] is CalendarCell) { row.Cells["Expression"].Value = DateTime.Now.Date; } row.Cells["Expression"].Tag = field; ((DataGridViewComboBoxCell)row.Cells["Criterion"]).DataSource = Criterion.GetAllowedOperations(field); }