Ejemplo n.º 1
0
        private void ButtonOk_Click(object sender, EventArgs e)
        {
            ActiveSheet.ClearConditionalFormats(ActiveSheet.ActiveRowIndex, ActiveSheet.ActiveColumnIndex);

            ConditionalFormat format = Formats[0];

            format.ComparisonOperator = expressionControl1.ComparisonOperator;

            if (format.ComparisonOperator != ComparisonOperator.IsTrue &&
                format.ComparisonOperator != ComparisonOperator.IsFalse &&
                format.ComparisonOperator != ComparisonOperator.IsEmpty)
            {
                if (format.ComparisonOperator == ComparisonOperator.Between ||
                    format.ComparisonOperator == ComparisonOperator.NotBetween)
                {
                    format.FirstCondition = expressionControl1.StartValue;
                    format.LastCondition  = expressionControl1.EndValue;
                    if (!string.IsNullOrEmpty(format.FirstCondition) && !string.IsNullOrEmpty(format.LastCondition))
                    {
                        ActiveSheet.SetConditionalFormat(ActiveSheet.ActiveRowIndex, ActiveSheet.ActiveColumnIndex, 1, 1, format.Style, format.ComparisonOperator, format.FirstCondition, format.LastCondition);
                    }
                }
                else
                {
                    format.FirstCondition = expressionControl1.StartValue;
                    if (!string.IsNullOrEmpty(format.FirstCondition))
                    {
                        ActiveSheet.SetConditionalFormat(ActiveSheet.ActiveRowIndex, ActiveSheet.ActiveColumnIndex, 1, 1, format.Style, format.ComparisonOperator, format.FirstCondition);
                    }
                }
            }

            Close();
        }