Beispiel #1
0
        /// <summary>
        ///   Initializes a new instance of the <see cref="DataGridViewColumnFilterControl" /> class.
        /// </summary>
        /// <param name="dataGridViewColumn">The data grid view column.</param>
        public DataGridViewColumnFilterControl(DataGridViewColumn dataGridViewColumn)
        {
            if (dataGridViewColumn == null)
            {
                throw new ArgumentNullException(nameof(dataGridViewColumn));
            }
            m_DataGridViewColumnFilter = new ColumnFilterLogic(dataGridViewColumn.ValueType, dataGridViewColumn.DataPropertyName);
            m_DataGridViewColumnFilter.PropertyChanged += FilterLogic_PropertyChanged;
            InitializeComponent();
            lblCondition.Text = dataGridViewColumn.HeaderText;

            var isDate = m_DataGridViewColumnFilter.ColumnDataType == typeof(DateTime);

            dateTimePickerValue.Visible = isDate;
            textBoxValue.Visible        = !isDate;

            comboBoxOperator.BeginUpdate();
            comboBoxOperator.Items.Clear();
            comboBoxOperator.Items.AddRange(ColumnFilterLogic.GetOperators(m_DataGridViewColumnFilter.ColumnDataType));
            comboBoxOperator.SelectedIndex = 0;
            comboBoxOperator.EndUpdate();
        }
        /// <summary>
        ///   Initializes a new instance of the <see cref="DataGridViewColumnFilterControl" /> class.
        /// </summary>
        /// <param name="columnDataType">Type of the column data.</param>
        /// <param name="dataGridViewColumn">The data grid view column.</param>
        public DataGridViewColumnFilterControl(Type columnDataType, DataGridViewColumn dataGridViewColumn)
        {
            Contract.Requires(dataGridViewColumn != null);
            Contract.Requires(dataGridViewColumn.DataPropertyName != null);

            m_DataGridViewColumnFilter = new ColumnFilterLogic(columnDataType, dataGridViewColumn.DataPropertyName);
            m_DataGridViewColumnFilter.PropertyChanged += FilterLogic_PropertyChanged;
            InitializeComponent();
            lblCondition.Text = dataGridViewColumn.HeaderText;
            Contract.Assume(dateTimePickerValue != null);
            Contract.Assume(comboBoxOperator != null);
            Contract.Assume(textBoxValue != null);

            var isDate = m_DataGridViewColumnFilter.ColumnDataType == typeof(DateTime);

            dateTimePickerValue.Visible = isDate;
            textBoxValue.Visible        = !isDate;

            comboBoxOperator.BeginUpdate();
            comboBoxOperator.Items.Clear();
            comboBoxOperator.Items.AddRange(m_DataGridViewColumnFilter.ColumnDataType == typeof(string)
        ? new object[]
            {
                ColumnFilterLogic.cOPcontains, ColumnFilterLogic.cOPbegins, ColumnFilterLogic.cOPends,
                ColumnFilterLogic.cOPequal, ColumnFilterLogic.cOPnotEqual, ColumnFilterLogic.cOPisNull,
                ColumnFilterLogic.cOPisNotNull, ColumnFilterLogic.cOpLonger, ColumnFilterLogic.cOPshorter
            }
        : new object[]
            {
                ColumnFilterLogic.cOPisNotNull, ColumnFilterLogic.cOPsmaller, ColumnFilterLogic.cOPsmallerequal,
                ColumnFilterLogic.cOPequal, ColumnFilterLogic.cOPnotEqual, ColumnFilterLogic.cOPbiggerEqual,
                ColumnFilterLogic.cOPbigger, ColumnFilterLogic.cOPisNull, ColumnFilterLogic.cOPisNotNull
            });
            comboBoxOperator.SelectedIndex = 0;
            comboBoxOperator.EndUpdate();
        }