Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

Incremental Search example

This example shows how incremental searching can be done programmatically. To allow searching, the View should not be in edit mode. Thus, the edit controller’s HideEdit method is used to close the currently active editor, if any. The search starts from the currently focused record. Thus, the sample below focuses the first record to start searching from it. The text to search is obtained from a TEdit control.

var
  AView: TcxCustomGridTableView;
//...
AView := TcxCustomGridTableView(Grid.FocusedView);
//Close an open editor if any
AView.Controller.EditingController.HideEdit(True);
//set focus to the first record
//to start the search from the beginning
AView.DataController.GotoFirst;
//start an incremental search within the tvFilmsCAPTION column
AView.DataController.Search.Locate(tvFilmsCAPTION.Index, Edit1.Text);
//...
//continue the search forward
AView.DataController.Search.LocateNext(True);
//...
//cancel the search
AView.DataController.Search.Cancel;