Skip to main content

VGridControlBase.FilterString Property

Gets or sets the filter criteria applied to the control in text format.

Namespace: DevExpress.XtraVerticalGrid

Assembly: DevExpress.XtraVerticalGrid.v23.2.dll

NuGet Packages: DevExpress.Win.Navigation, DevExpress.Win.VerticalGrid

Declaration

[DefaultValue(null)]
[DXCategory("Behavior")]
public string FilterString { get; set; }

Property Value

Type Default Description
String null

A string that specifies the filter criteria applied to the control.

Remarks

See the Filter Strings section below to learn how to build filter expressions in text formats.

When you set the FilterString property, the specified filter string is parsed to create a corresponding CriteriaOperator object. The created CriteriaOperator object is then assigned to the VGridControlBase.FilterCriteria property.

Similarly, when you set the VGridControlBase.FilterCriteria property, the FilterString property is set to the text representation of the specified filter criteria.

Filter Strings

The simplest text filter expression has the following notation: “[FieldName] = Value”. This selects records that have a Value in the column with the specified field name.

In filter expressions, you can use various comparison operators that are dependent upon the types of field names. For instance, if a FieldName is of the numeric or string type, you can use these operators: >, <, <>. For fields of the string type, you can also use the ‘like’ operator to implement a partial string comparison. The following table covers available comparison operators.

Comparison Operator

Description

Example

=

Equal to.

The operator can be applied to numeric, date-time, string and Boolean values.

[ProductID] = 999

>

Greater than.

The operator can be applied to numeric, date-time and string values.

[ProductName] > 'Uncle'

<

Less than.

The operator can be applied to numeric, date-time and string values.

[UnitsInStock] < 100

>=

Greater than or equal to.

The operator can be applied to numeric, date-time and string values.

[BirthDate] >= #01/01/1980#

<=

Less than or equal to.

The operator can be applied to numeric, date-time and string values.

[CreatedDate] <= #10/2/2006#

<>

Not equal to.

The operator can be applied to numeric, date-time, string and Boolean values.

[Priority] <> 'Low'

LIKE

Operator ‘LIKE’.

The operator is used for a partial string comparison. It returns TRUE if the value being tested matches the specified pattern.

You can use the ‘%’ and ‘_’ symbols as wildcards in patterns. The ‘%’ wildcard substitutes any number of characters. The ‘_’ character is used to represent any single character.

[ProductName] LIKE '%Sauce%'

NOT LIKE

Operator ‘NOT LIKE’.

The operator is used for partial string comparison. It returns TRUE if the value being tested doesn’t match the specified pattern. See the description of the LIKE operator for more information.

[IssueSubject] NOT LIKE 'Help:%'

IS NULL

Checks whether the value being tested is the NULL value.

[Region] IS NULL

IS NOT NULL

Checks whether the value being tested is not the NULL value.

[Region] IS NOT NULL

String constants must be enclosed within single quote characters. If a single quote character needs to be included as a literal to a filter, it must be doubled. Example:

[ProductID] LIKE 'Uncle Bob''s%'

Date-time constants must be wrapped with the ‘#’ characters and represented using a culture-independent (invariant) format. The invariant culture is based on the English culture, but some of the idiosyncratic English formats have been replaced by more globally-accepted formats. Below are some of the culture-independent formats for representing date-time values.

MM/dd/yyyy    07/30/2008

dd MMM yyyy    30 JUL 2008

yyyy-MM-dd    2008-07-30

yyyy-MM-ddTHH:mm:ss    2008-07-30T22:59:59

yyyy-MM-dd HH:mm:ssZ    2008-07-30 15:59:59Z

Example:

[CreatedDate] <= #07/30/2008#

To learn more about invariant cultures, refer to MSDN.

If the ‘%’, ‘_’ or ‘[‘ character must be used as a literal in a pattern for the LIKE operator, enclose it with square brackets (‘[]’). Example:

[Note] LIKE '%[_]%'

Filter expressions can contain multiple clauses combined by logical AND, AND NOT, OR and OR NOT operators. Clauses can be grouped using parentheses. Example:

[Type] = 'Request' AND NOT ([Status] = 'Fixed' OR [Status] = 'Rejected')

See Also