Skip to main content

ColumnView.CustomRowFilter Event

Allows you to hide or show specific rows that exist in the data source (regardless of the grid’s filter).

Namespace: DevExpress.XtraGrid.Views.Base

Assembly: DevExpress.XtraGrid.v22.2.dll

NuGet Package: DevExpress.Win.Grid


public event RowFilterEventHandler CustomRowFilter

Event Data

The CustomRowFilter event's data class is RowFilterEventArgs. The following properties provide information specific to this event:

Property Description
Handled Gets or sets whether the event is handled and therefore no default processing is required.
ListSourceRow Gets the index in the data source of the row currently being processed. Row handles are not data source indexes, see the Accessing Rows in Code. Row Handles section of the “Rows” article for more information.
Visible Gets or sets whether the current record must be visible in a View.


By default, the grid displays all the records from a data source that match the filter criteria specified by a View (the filter criteria are specified by the GridColumn.FilterInfo properties of the View’s columns). The records that do not match these criteria are not displayed.

The CustomRowFilter event provides a more flexible way to control a record’s visibility in a View. It can be handled to hide specific records (even if they match the current filter criteria) or make particular records visible (even if they do not match the current criteria).

This event fires for each record. The currently processed record is identified by the RowFilterEventArgs.ListSourceRow parameter, and this specifies the record’s zero-based index in the data source.

Set the RowFilterEventArgs.Visible parameter to false and the RowFilterEventArgs.Handled parameter to true to hide the currently processed record.

To make the record visible regardless of the View’s filter, set both the RowFilterEventArgs.Visible and RowFilterEventArgs.Handled parameters to true.

If the RowFilterEventArgs.Handled parameter is set to false the record’s visibility will be determined by the filter that is applied to the View. That is, the record will be visible only if it matches the filter. Otherwise, it will be hidden.


If you need to get or set specific cell values while handling the CustomRowFilter event, use methods provided by the bound data source. The event’s ListSourceRowIndex parameter allows you to identify the current data row. To get values in a specific row in the data source, you can use the ColumnView.GetListSourceRowCellValue method or methods provided by row objects. To get cell values, do not use methods provided by the Grid Control that have a rowHandle parameter (e.g., ColumnView.GetRowCellValue).


The CustomRowFilter event is not supported in Large Data Sources: Server and Instant Feedback Modes.


If an exception is raised within a CustomRowFilter event handler, it is silently swallowed by the grid control. In addition, the grid stops filtering rows and all subsequent rows will be hidden. To catch and re-throw an exception that might occur within the CustomRowFilter event handler, enclose the code in your CustomRowFilter event handler with the try…catch block.

Example 1: How to Keep Specific Rows Always Visible

The following code shows how to make the rows that contain the “USA” value in the ‘Country’ field always visible regardless of the filter applied to a View. The ColumnView.CustomRowFilter event is handled to control the visibility of the rows.

using DevExpress.XtraGrid.Views.Base;

private void gridView1_CustomRowFilter(object sender, RowFilterEventArgs e) {
    ColumnView view = sender as ColumnView;
    string country = view.GetListSourceRowCellValue(e.ListSourceRow, "Country").ToString();
    // Check whether the current row contains "USA" in the "Country" field.
    if (country == "USA") {
        // Make the current row visible.
        e.Visible = true;
        // Prevent default processing, so the row will be visible 
        // regardless of the view's filter.
        e.Handled = true;

Example 2: How to Hide Individual Rows

Handle the CustomRowFilter event and set the e.Visible property to false. You also need to enable the e.Handled property.

var rowIndex;

private void gridView1_CustomRowFilter(object sender, RowFilterEventArgs e) {    
    if (e.ListSourceRow == rowIndex) {
        e.Visible = false;
        e.Handled = true;

The following GitHub example illustrates how to implement a helper class with ShowRow and HideRow methods that toggle row visibility:

View Example

See Also