# Filtered View

## Content

`C1FilterEditor`, available in the `C1.Win.DataFilter` namespace, provides the [View](/componentone/api/win/online-datafilter/dotnet-api/C1.Win.DataFilter.10/C1.Win.DataFilter.C1FilterEditor.View.html) property to access the result set generated by the currently applied filter. The property returns the filtered records as an `IReadOnlyList<object>`.

```csharp
public IReadOnlyList<object> View { get; }
```

The `View` collection can be assigned to a data-bound control, such as FlexGrid, to display the records that match the current filter expression.
![C1WinForms FilterEditor - Filtered View demo](https://cdn.mescius.io/document-site-files/images/17b51e8a-8741-4303-8d01-461f0bd662e6/FilteredView-20260811.bf797f.gif?width=800)

***

## View Property for Filtered Results

The [View](/componentone/api/win/online-datafilter/dotnet-api/C1.Win.DataFilter.10/C1.Win.DataFilter.C1FilterEditor.View.html) property reflects the filter applied to the data assigned to `C1FilterEditor.DataSource`. The following steps configure the filter and display the resulting records:

1. Assign the source data to the [DataSource](/componentone/api/win/online-datafilter/dotnet-api/C1.Win.DataFilter.10/C1.Win.DataFilter.C1FilterEditor.DataSource.html) property.
2. Define a filter expression through the FilterEditor UI or programmatically by using a `CombinationExpression` or `OperationExpression`.
3. Apply the filter expression by using the [ApplyFilterAsync()](/componentone/api/win/online-datafilter/dotnet-api/C1.Win.DataFilter.10/C1.Win.DataFilter.C1FilterEditor.ApplyFilterAsync.html) method.
4. Assign the `View` collection to the target data display control.
5. Handle the [FilterChanged](/componentone/api/win/online-datafilter/dotnet-api/C1.Win.DataFilter.10/C1.Win.DataFilter.C1FilterEditor.FilterChanged.html) event to keep the displayed data synchronized with changes to the filter.

The following code applies a predefined filter and assigns `filterEditor.View` to `flexGrid.DataSource`. The `FilterChanged` event updates the grid when the filter state changes.

```csharp
using C1.Win.DataFilter;

public partial class FilterEditor : UserControl
{
    public FilterEditor()
    {
        InitializeComponent();
        filterEditor.CustomEditorInitializing += FilterEditor_CustomEditorInitializing;
    }

    private void ApplyDataSource()
    {
        var dt = DataService.GetDataSource();
        filterEditor.DataSource = dt;
        flexGrid.DataSource = dt; // Initial bind — full, unfiltered data
    }

    private async Task ApplyFilterAsync()
    {
        var filterExpression = GetPredefinedFilter();
        filterEditor.SetExpression(filterExpression);
        await filterEditor.ApplyFilterAsync(); // Apply the expression asynchronously
        flexGrid.DataSource = filterEditor.View; // Refresh the grid from the filtered View
    }

    // Keep the grid synced any time the user changes the filter in the UI
    private void filterEditor_FilterChanged(object sender, EventArgs e)
    {
        flexGrid.DataSource = filterEditor.View;
    }
}
```

>type=note
> <span data-loadable-vc-wrapper="true" data-ssr-placeholder-replace="Hm6N8:EfLS5:z8NN7:qz-Pe:OP-5u-0">Note: </span>**<span data-loadable-vc-wrapper="true" data-ssr-placeholder-replace="Hm6N8:EfLS5:z8NN7:qz-Pe:OP-5u-0">FilterEditor.DataSource</span>**<span data-loadable-vc-wrapper="true" data-ssr-placeholder-replace="Hm6N8:EfLS5:z8NN7:qz-Pe:OP-5u-0"> retains the original data source. After filtering, </span>**<span data-loadable-vc-wrapper="true" data-ssr-placeholder-replace="Hm6N8:EfLS5:z8NN7:qz-Pe:OP-5u-0">FlexGrid.DataSource</span>**<span data-loadable-vc-wrapper="true" data-ssr-placeholder-replace="Hm6N8:EfLS5:z8NN7:qz-Pe:OP-5u-0"> uses </span>**<span data-loadable-vc-wrapper="true" data-ssr-placeholder-replace="Hm6N8:EfLS5:z8NN7:qz-Pe:OP-5u-0">FilterEditor.View</span>**<span data-loadable-vc-wrapper="true" data-ssr-placeholder-replace="Hm6N8:EfLS5:z8NN7:qz-Pe:OP-5u-0"> to display the current filtered result set.</span>

***

## Filtering API Reference

The following members support filter configuration, application, and access to filtered results in `C1FilterEditor`.

| Member | Description |
| ------ | ----------- |
| [DataSource](/componentone/api/win/online-datafilter/dotnet-api/C1.Win.DataFilter.10/C1.Win.DataFilter.C1FilterEditor.DataSource.html) property | Represents the complete, unfiltered data set used to generate filter fields. |
| [DataMember](/componentone/api/win/online-datafilter/dotnet-api/C1.Win.DataFilter.10/C1.Win.DataFilter.C1FilterEditor.DataMember.html) property | Gets or sets the name of a specific record set within the `DataSource`. |
| [GetExpression()](/componentone/api/win/online-datafilter/dotnet-api/C1.Win.DataFilter.10/C1.Win.DataFilter.C1FilterEditor.GetExpression.html) method | Gets the current filter expression. |
| [SetExpression()](/componentone/api/win/online-datafilter/dotnet-api/C1.Win.DataFilter.10/C1.Win.DataFilter.C1FilterEditor.SetExpression.html) method | Sets the filter expression, including filter operations and logical combinations. |
| [ApplyFilterAsync()](/componentone/api/win/online-datafilter/dotnet-api/C1.Win.DataFilter.10/C1.Win.DataFilter.C1FilterEditor.ApplyFilterAsync.html) method | Applies the current filter expression to `DataSource` and refreshes `View`. |
| [ClearFilter()](/componentone/api/win/online-datafilter/dotnet-api/C1.Win.DataFilter.10/C1.Win.DataFilter.C1FilterEditor.ClearFilter.html) method | Removes all filter expressions from the current filter configuration. |
| [View](/componentone/api/win/online-datafilter/dotnet-api/C1.Win.DataFilter.10/C1.Win.DataFilter.C1FilterEditor.View.html) property | Provides the filtered result set as an `IReadOnlyList<object>` based on the filter applied to `DataSource`. |
| [FilterChanging](/componentone/api/win/online-datafilter/dotnet-api/C1.Win.DataFilter.10/C1.Win.DataFilter.C1FilterEditor.FilterChanging.html) event | Occurs before the filter state changes and allows the pending filter operation to be canceled. |
| [FilterChanged](/componentone/api/win/online-datafilter/dotnet-api/C1.Win.DataFilter.10/C1.Win.DataFilter.C1FilterEditor.FilterChanged.html) event | Occurs after the filter state changes or a filter is applied, providing access to the updated `View` collection. |
| [CustomEditorInitializing](/componentone/api/win/online-datafilter/dotnet-api/C1.Win.DataFilter.10/C1.Win.DataFilter.C1FilterEditor.CustomEditorInitializing.html) event | Occurs before the filter editor is initialized and allows custom editor configuration during initialization. |
