Skip to main content
A newer version of this page is available. .

How to: Dynamically Control Record Visibility in XtraGrid

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;
    }
}