ComponentOne List for WinForms
Customization / Row Filter
In This Topic
    Row Filter
    In This Topic

    RowFilter lets you narrow down display records according to a specified condition applied on a column field. It is especially useful in case of large number of list items, as it lets you easily analyze data by displaying a specific type of records only. Please note that RowFilter can only be applied if the list is bound to a data source.

    Row Filter in List

    To enable filtering using row filter, you can use the RowFilter property of the DataView class. The following code demonstrates how to modify the default view of the data table by using the RowFilter property. In this example, we apply filtering on "CategoryID" column field.

    C#
    Copy Code
    //set the row filter by setting default view of data source
    dt.DefaultView.RowFilter = "CategoryId = 1";
    //bind to list
    c1List1.DataSource = dt;
    

    Clear Filter

    To return to the default view or undo the filter operation, you need to set the value of RowFilter property to an empty string as shown in the following code. In this example the code is added to the Clear button's Click event:

    C#
    Copy Code
    //clear the filter
    dt.DefaultView.RowFilter = " ";