/// <summary>
        /// Builds the filter expression and raises the FilterExpressionBuilding event
        /// </summary>
        /// <param name="sender">The event source.</param>
        /// <param name="e">The <see cref="System.ComponentModel.CancelEventArgs"/> userPermissions containing the event data.</param>
        /// <remarks>
        /// Override <b>OnFilterExpressionBuilding</b> to provide a filter expression construction
        /// logic and to set the values of the <see cref="DgvBaseColumnFilter.FilterExpression"/> and <see cref="DgvBaseColumnFilter.FilterCaption"/> properties.
        /// The <see cref="DgvFilterManager"/> will use these properties in constructing the whole filter expression and to change the header text of the filtered column.
        /// Otherwise, you can create an event handler and set the <i>Cancel</i> ctl of event argument to true, to skip standard filter expression building logic.
        /// </remarks>
        protected override void OnFilterExpressionBuilding(object sender, CancelEventArgs e)
        {
            base.OnFilterExpressionBuilding(sender, e);

            if (e.Cancel)
            {
                FilterManager.RebuildFilter();
                return;
            }

            FilterResult filterResult = new FilterResult();

            filterResult.Caption = this.OriginalDataGridViewColumnHeaderText;

            if (this.checkBoxSelectNull.Checked)
            {
                filterResult.Expression = GetNullCondition(this.DataGridViewColumn.DataPropertyName);
                filterResult.Caption   += "\n= Ø";
            }

            if (this._checkedItems.Count > 0)
            {
                if (!String.IsNullOrEmpty(filterResult.Expression))
                {
                    filterResult.Expression += " OR ";
                }

                filterResult.Expression += this.DataGridViewColumn.DataPropertyName + " IN (";
            }

            Int32 i = 0;

            foreach (String filter in this._checkedItems)
            {
                if (!String.IsNullOrEmpty(filter))
                {
                    filterResult = this.ApplyFilter(filterResult, filter, i);
                }

                i++;
            }

            if (this._checkedItems.Count > 0)
            {
                filterResult.Expression += filterResult.Expression.Substring(0, filterResult.Expression.Length - 1) + ")";
            }

            if (i > this.MaxCaptionItems)
            {
                filterResult.Caption += "\n...";
            }

            if (!String.IsNullOrEmpty(filterResult.Expression))
            {
                FilterExpression = filterResult.Expression;
                FilterCaption    = filterResult.Caption;
                FilterManager.RebuildFilter();
            }
            else
            {
                FilterManager.ActivateFilter(false, this.DataGridViewColumn.Index);
            }
        }
Example #2
0
 private void tsOK_Click(object sender, EventArgs e)
 {
     FilterManager.ActivateFilter(true);
     this.Popup.Close();
 }
Example #3
0
 private void tsRemove_Click(object sender, EventArgs e)
 {
     FilterManager.ActivateFilter(false);
     this.Popup.Close();
 }
 private void lblDelete_Click(object sender, EventArgs e)
 {
     FilterManager.ActivateFilter(false);
     Popup.Close();
 }