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;