示例#1
0
        protected virtual void OnDgvConditionsCellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            var row    = dgvConditions.Rows[e.RowIndex];
            var column = dgvConditions.Columns[e.ColumnIndex];
            var cell   = row.Cells[e.ColumnIndex];

            if (cell != null && cell.Value != null)
            {
                var cellValueString = cell.Value.ToString();
                using (var frmString = new frmValueEditor(cellValueString))
                {
                    if (column.Name == "col" + nameof(ConditionValue.Condition))
                    {
                        frmString.ShowDialog();
                        if (frmString.RetValDisplay != null)
                        {
                            cell.Value = frmString.RetValDisplay;
                        }
                    }
                    else if (column.Name == "col" + nameof(ConditionValue.DisplayValue))
                    {
                        frmString.ShowDialog();
                        if (frmString.RetValDisplay != null)
                        {
                            cell.Value = frmString.RetValDisplay;
                            var valueCell = row.Cells["col" + nameof(ConditionValue.Value)];
                            if (valueCell != null)
                            {
                                valueCell.Value = frmString.RetValDisplay;
                            }
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Overridable function, which is called by a double click within a conditional field cell of dgvConditionalFields
        /// </summary>
        /// <param name="sender">DataGridView</param>
        /// <param name="e">DataGridViewCellEventArgs</param>
        protected virtual void OnDgvConditionalFieldCellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            var row    = dgvConditionalFields.Rows[e.RowIndex];
            var column = dgvConditionalFields.Columns[e.ColumnIndex];
            var cell   = row.Cells[e.ColumnIndex];

            if (cell != null && cell.Value != null)
            {
                var cellValueString = cell.Value.ToString();
                var nameCell        = row.Cells["col" + nameof(ConditionalFieldResultDisplay.Name)];

                var condFieldTemplate = this.conditionalFieldsTemplate.Where(x => x.Name == nameCell.Value.ToString()).FirstOrDefault();
                if (condFieldTemplate != null)
                {
                    var conditionOptions        = new List <string>();
                    var conditionOptionsDisplay = new List <string>();
                    foreach (var conditionValue in condFieldTemplate.ConditionValues)
                    {
                        conditionOptions.Add(conditionValue.Value);
                        conditionOptionsDisplay.Add(conditionValue.DisplayValue);
                    }

                    using (var frmCbx = new frmValueEditor(cellValueString, conditionOptions, conditionOptionsDisplay))
                    {
                        if (column.Name == "col" + nameof(ConditionalFieldResultDisplay.DisplayValue))
                        {
                            var dexForm = FindForm();
                            if (dexForm != null)
                            {
                                frmCbx.Icon = dexForm.Icon;
                                frmCbx.Font = dexForm.Font;
                            }

                            var typeCell = row.Cells["col" + nameof(ConditionalFieldResultDisplay.ConditionalFieldType)];
                            frmCbx.ConditionalFieldType = (ConditionalFieldType)(typeCell.Value);
                            frmCbx.IndividualConditionalValueButtonClicked += FrmCbx_IndividualConditionalValueButtonClicked;

                            frmCbx.ShowDialog();
                            if (string.IsNullOrWhiteSpace(frmCbx.RetVal) == false)
                            {
                                cell.Value = frmCbx.RetValDisplay;
                                var valueCell = row.Cells["col" + nameof(ConditionalFieldResultDisplay.Value)];
                                if (valueCell != null)
                                {
                                    valueCell.Value = frmCbx.RetVal;
                                }
                            }
                        }
                    }
                }
            }
        }
        protected virtual void OnFrmComboBoxIndividualConditionalValueButtonClick(object sender, EventArgs e)
        {
            var frmValEdit = sender as frmValueEditor;

            if (frmValEdit != null)
            {
                using (var individualFrmValEdit = new frmValueEditor("..."))
                {
                    var dexForm = FindForm();
                    if (dexForm != null)
                    {
                        individualFrmValEdit.Icon = dexForm.Icon;
                        individualFrmValEdit.Font = dexForm.Font;
                    }
                    individualFrmValEdit.ShowDialog();
                    if (string.IsNullOrWhiteSpace(individualFrmValEdit.RetValDisplay) == false)
                    {
                        frmValEdit.RetVal        = individualFrmValEdit.RetValDisplay;
                        frmValEdit.RetValDisplay = individualFrmValEdit.RetValDisplay;
                        frmValEdit.Close();
                    }
                }
            }
        }