Skip to main content

VGridControl.ActiveFilter Property

Provides access to the collection of filters applied to particular rows, and the overall filter.

Namespace: DevExpress.XtraVerticalGrid

Assembly: DevExpress.XtraVerticalGrid.v24.2.dll

Declaration

[XtraSerializableProperty(XtraSerializationVisibility.Hidden)]
[DXCategory("Behavior")]
public VGridFilter ActiveFilter { get; }

Property Value

Type Description
DevExpress.XtraVerticalGrid.VGridFilter

A DevExpress.XtraVerticalGrid.VGridFilter object representing the collection of filters applied to the rows.

Remarks

The ActiveFilter property of the DevExpress.XtraVerticalGrid.VGridFilter type provides a number of properties which can be used to get details on the filter criteria applied to the grid rows:

  • the indexer allows you to obtain the filter criterion for a particular row. You can also iterate through the collection using the zero-based index;

    using DevExpress.XtraVerticalGrid;
    // Use row properties to obtain the required filter information.
    // If no filter is assigned to the specified row, null/Nothing is returned.
    FilterInfo addressFliterInfo = vGridControl1.ActiveFilter[rowAddress.Properties];
    // Alternatively, get the required row properties by a filed name.
    FilterInfo addressFliterInfo = vGridControl1.ActiveFilter[vGridControl1.GetRowPropertiesByFieldName("Address")];
    // You can also use the zero-based index to iterate the collection.
    for (int i = 0; i < vGridControl1.ActiveFilter.Count; i++) {
        FilterInfo fliterInfo = vGridControl1.ActiveFilter[i];
        // ...
    }
    

    The returned DevExpress.XtraVerticalGrid.FilterInfo object exposes the following properties:

  • the ActiveFilter.Criteria property gets the overall filter criterion which is a conjunction of filters for all rows. The VGridControl.ActiveFilterCriteria property is equivalent to the ActiveFilter.Criteria property;
  • the ActiveFilter.Expression property returns the textual representation of the overall filter criteria, which is displayed in the control’s filter panel. The VGridControl.ActiveFilterString property is equivalent to the ActiveFilter.Expression property.
  • the NonRowFilterCriteria property gets or sets a filter which is applied, but not associated with a particular row using the RowProperties.FilterInfo property;
  • the Changed event fires when a row filter changes.

To temporarily disable/enable the filter criteria, use the VGridControl.ActiveFilterEnabled property.

Example

The following code shows how to add a filter condition to the control using the VGridControl.ActiveFilter property. The filter condition selects records whose City field starts with ‘S’.

using DevExpress.XtraVerticalGrid.Rows;
// ...
vGridControl1.ActiveFilter.Add(vGridControl1.GetRowPropertiesByFieldName("City"), new VGridRowFilterInfo("[City] Like 'S%'"));
See Also