Back to Devexpress

ColumnView.ColumnFilterChanged Event

windowsforms-devexpress-dot-xtragrid-dot-views-dot-base-dot-columnview-6617b865.md

latest3.7 KB
Original Source

ColumnView.ColumnFilterChanged Event

Occurs when a column’s filter condition changes. This event also raises when the Find Panel finishes its search.

Namespace : DevExpress.XtraGrid.Views.Base

Assembly : DevExpress.XtraGrid.v25.2.dll

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

Declaration

csharp
[DXCategory("Property Changed")]
public event EventHandler ColumnFilterChanged
vb
<DXCategory("Property Changed")>
Public Event ColumnFilterChanged As EventHandler

Event Data

The ColumnFilterChanged event's data class is EventArgs.

Remarks

If the column’s OptionsColumnFilter.AllowFilter option is enabled, users can use the column’s Filter DropDown or the column header context menu to change filter conditions. To change filter conditions in code, modify the GridColumn.FilterInfo property.

You can also apply filters by multiple columns. Refer to the Filter and Search topic for more details.

Each time a column filter condition changes, the ColumnFilterChanged event occurs.

The code sample below illustrates how to detect if the user has applied any filters to the grid.

csharp
using DevExpress.XtraGrid.Views.Grid;

..

gridView1.ColumnFilterChanged += GridView1_ColumnFilterChanged;

private void GridView1_ColumnFilterChanged(object sender, EventArgs e)
{
    GridView view = sender as GridView;
    if (view.ActiveFilterString == "")
        XtraMessageBox.Show("The grid has no filters applied");
    else
        XtraMessageBox.Show(string.Format("The grid has the following filter applied: {0}", view.ActiveFilterString));

}
vb
Imports DevExpress.XtraGrid.Views.Grid

..

Private gridView1.ColumnFilterChanged += AddressOf GridView1_ColumnFilterChanged

Private Sub GridView1_ColumnFilterChanged(ByVal sender As Object, ByVal e As EventArgs)
    Dim view As GridView = TryCast(sender, GridView)
    If view.ActiveFilterString = "" Then
        XtraMessageBox.Show("The grid has no filters applied")
    Else
        XtraMessageBox.Show(String.Format("The grid has the following filter applied: {0}", view.ActiveFilterString))
    End If

End Sub

See Also

ActiveFilter

FilterInfo

Filter and Search

ColumnView Class

ColumnView Members

DevExpress.XtraGrid.Views.Base Namespace