AutoFilterColumn.ApplyCustomFilter(FilterValue, FilterComparisonOperator, FilterValue, FilterComparisonOperator, Boolean) Method
Applies a custom filter based on the compound filter expression.
Namespace: DevExpress.Spreadsheet
Assembly: DevExpress.Spreadsheet.v24.1.Core.dll
NuGet Package: DevExpress.Spreadsheet.Core
Declaration
void ApplyCustomFilter(
FilterValue firstCriteria,
FilterComparisonOperator firstCriteriaOperator,
FilterValue secondCriteria,
FilterComparisonOperator secondCriteriaOperator,
bool criterionAnd
)
Parameters
Name | Type | Description |
---|---|---|
firstCriteria | FilterValue | A FilterValue object that specifies the first filter criterion value. |
firstCriteriaOperator | FilterComparisonOperator | A FilterComparisonOperator enumeration member that defines the comparison operator for the first filter criterion. |
secondCriteria | FilterValue | A FilterValue object that specifies the second filter criterion value. |
secondCriteriaOperator | FilterComparisonOperator | A FilterComparisonOperator enumeration member that defines the comparison operator for the second filter criterion. |
criterionAnd | Boolean | A Boolean value indicating whether the logical operator "AND" should be used to combine two filter criteria. If false, the "OR" operator is used. |
Remarks
Use the ApplyCustomFilter method to filter values by two criteria, as illustrated in the example below.
Worksheet worksheet = workbook.Worksheets["Regional sales"];
workbook.Worksheets.ActiveWorksheet = worksheet;
// Enable filtering for the specified cell range.
CellRange range = worksheet["B2:E23"];
worksheet.AutoFilter.Apply(range);
// Filter values in the "Reported Date" column to display dates that are between June 1, 2014 and February 1, 2015.
worksheet.AutoFilter.Columns[3].ApplyCustomFilter(new DateTime(2014, 6, 1), FilterComparisonOperator.GreaterThanOrEqual, new DateTime(2015, 2, 1), FilterComparisonOperator.LessThanOrEqual, true);
You can also use wildcards and the FilterValue.FilterByBlank value to perform more versatile filtering.
Worksheet worksheet = workbook.Worksheets["Regional sales"];
workbook.Worksheets.ActiveWorksheet = worksheet;
// Enable filtering for the specified cell range.
CellRange range = worksheet["B2:E23"];
worksheet.AutoFilter.Apply(range);
// Filter values in the "Product" column that contain "Gi" and include empty cells.
AutoFilterColumn products = worksheet.AutoFilter.Columns[1];
products.ApplyCustomFilter("*Gi*", FilterComparisonOperator.Equal, FilterValue.FilterByBlank, FilterComparisonOperator.Equal, false);
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the ApplyCustomFilter(FilterValue, FilterComparisonOperator, FilterValue, FilterComparisonOperator, Boolean) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.