Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Collapse]Data Grid
   [Expand]Getting Started
   [Expand]Binding to Data
   [Expand]Grid View
   [Expand]View Technology
   [Expand]Grouping
   [Expand]Sorting
   [Expand]Summaries
   [Expand]Data Editing
   [Collapse]Filtering and Locating Rows
    [Expand]Filtering
     Locating Rows in Code
     Incremental Search
     Searching via Find Panel
     Tutorial: Incremental Search
     Tutorial: Search/Find Panel
   [Expand]Focus and Selection Handling
   [Expand]Processing Rows
   [Expand]Formatting Cell Values
   [Expand]Master-Detail Relationships
   [Expand]Asynchronous Image Load
   [Expand]Export and Printing
   [Expand]Appearance and Conditional Formatting
   [Expand]Batch Modifications
   [Expand]Hit Information
   [Expand]Hints
   [Expand]Popup Menus
   [Expand]Saving and Restoring Layouts
   [Expand]Visual Elements
   [Expand]Design-Time Features
   [Expand]Examples
   [Expand]End-User Capabilities
    Included Components
  [Expand]Vertical Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Diagrams
  [Expand]Gauges
  [Expand]Map Control
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]Printing-Exporting
  [Expand]PDF Viewer
   Reporting
  [Expand]Snap
  [Expand]TreeMap Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Tutorial: Incremental Search

This walkthrough is a transcript of the Incremental Search video available on the DevExpress YouTube Channel.

The tutorial will show you how to enable the Incremental Search feature for the entire view or individual columns. You will also learn how to perform custom actions in response to search string changes and how to initiate or end the search from code.

Expanded Enabling the Incremental Search Feature

To enable the incremental search, select the View, expand its GridView.OptionsBehavior property and enable the GridOptionsBehavior.AllowIncrementalSearch option.

Run the application to see this feature in action.

Expanded Using the Incremental Search Feature

First, search for a record by product name. Focus the corresponding column and then start typing the search text. Type 'c' to move focus to the first row where product name starts with this character. Then, type 'h' to locate a record where the product name starts with 'ch', and so on.

There may be several rows containing cells matching the search criteria. To continue searching forward using the same criterion, press the CTRL+DOWN ARROW key combination. To return back, press CTRL+UP ARROW. You can also use BACKSPACE to modify the search string.

In a similar manner, you can focus another column to search against its values.

Expanded Disabling Incremental Search for Individual Columns

Close the application and disable the incremental search for one of the columns. Select the Category column, expand the GridColumn.OptionsColumn property and set the OptionsColumn.AllowIncrementalSearch option to false.

Run the application and focus the Category column to see that the incremental search no longer works. You can still use the feature in other columns.

Expanded Responding to Search String Changes

You might want to respond to changes in the search string while users search for records. To do this, handle the View's BaseView.KeyUp event. In the event handler, call the DisplayIncrementalSearchText method, which in turn obtains the current search text using the View's ColumnView.GetIncrementalText method and displays this string in the status bar.

Run the application to see the result. Start incremental search to see that the status bar displays the current search string.

Expanded Starting and Stopping Incremental Search in Code

You can also initiate or end incremental search operations from code. The Start Incremental Search and Stop Incremental Search buttons will be used for this purpose. In the first button's Click event handler, call the View's GridView.StartIncrementalSearch method and pass the 'cha' text as a parameter. Display this text in the status bar using the previously discussed DisplayIncrementalSearchText method. Focus to the Product Name column via the View's ColumnView.FocusedColumn property.

The Click event handler for the second button simply calls the GridView.StopIncrementalSearch method.

Run the application. When you click the Start Incremental Search button, the grid locates the nearest record where the product name starts with 'cha', and displays this text in the status bar. You can continue typing to narrow down the search. The Stop Incremental Search button disables the incremental search mode.

Expanded See Also

How would you rate this topic?​​​​​​​