How to: Implement Custom Filtering

  • 2 minutes to read

This example demonstrates how to implement custom filtering in the DXGrid control.

View Example

<Window x:Class="CustomFiltering.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
        Title="Window1" Height="300" Width="300">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="36" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <StackPanel Grid.Row="0" Orientation="Horizontal">
            <CheckBox Name="chkHideEven" Margin="7,0,7,0" VerticalAlignment="Center" 
                      Content="Hide Even Rows"
                      Checked="chk_CheckedOrUnchecked"
                      Unchecked="chk_CheckedOrUnchecked" />
            <CheckBox Name="chkHideOdd" VerticalAlignment="Center" Content="Hide Odd Rows"
                      Checked="chk_CheckedOrUnchecked" Unchecked="chk_CheckedOrUnchecked" />
        </StackPanel>
        <dxg:GridControl Name="grid" Grid.Row="1" AutoGenerateColumns="AddNew" CustomRowFilter="grid_CustomRowFilter">
            <dxg:GridControl.View>
                <dxg:TableView Name="view" AutoWidth="True" ShowGroupPanel="False" NavigationStyle="None" />
            </dxg:GridControl.View>
        </dxg:GridControl>
    </Grid>
</Window>