We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to perform the incremental search in WPF DataGrid (SfDataGrid)?

Platform: WPF |
Control: SfDataGrid
Tags: search

You can increase the searching operation in WPF DataGrid (SfDataGrid) by using SearchHelper class. The SearchHelper class is used to perform the search operation in the SfDataGrid. The SearchBrush property can be used to highlight the search text of grid with default color(yellow). This feature can be added to the SfDataGrid by including the namespace as Syncfusion.UI.Xaml.Grid.Helpers.


You can use the Search method of SearchHelper class to search the record. From the attached sample, to enable the search panel, select the row in the grid and press Ctrl+F key in the keyboard.




Below code illustrates on to find the previous and next matched records based on the given text by using FindNext and FindPrevious method. You can use the navigation arrow in the search panel to move the focus to that searched record from the attached sample.


// move the current cell and search the next records in the SfDataGrid
// move the current cell and search the previous records in the SfDataGrid


Below code will be used to search only the selected columns by overriding SearchCell method of SearchHelper.


DataGrid.SearchHelper = new SearchHelperExt(DataGrid);
public class SearchHelperExt : SearchHelper
    public SearchHelperExt(SfDataGrid datagrid)
        : base(datagrid)
    protected override bool SearchCell(DataColumnBase column, object record, bool ApplySearchHighlightBrush)
                 // to get the columnIndex of selected row of the SfDataGrid
        var colIndex = DataGrid.SelectionController.CurrentCellManager.CurrentCell.ColumnIndex;
        // to get the mapping name of based on the column index 
        var mapName = DataGrid.Columns[colIndex].MappingName;
        // based on the mapping name, the particular searching will be enabled other columns the searching will be excluded. 
        if (column.GridColumn.MappingName == mapName)
            return base.SearchCell(column, record, ApplySearchHighlightBrush);
        return false;



Refer the below example which demonstrates an incremental search with the SfDataGrid.


Increase the search operation in WPF DataGrid

View sample in GitHub.

2X faster development

The ultimate WPF UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile