Example: Searching, Behavior.IncSearch, Behavior.IncSearchItem, Behavior.ExpandOnIncSearching, SearchingText, CancelSearching
The following sample implements the incremental search feature using code. The IncSearch method accepts the following parameters:
ASearchColumn represents the column whose values are searched.
ASearchingText provides the search string.
AExpandOnIncSearching specifies whether a collapsed node should expand if one of its child nodes contains a suitable value. The parameter defaults to True.
procedure IncSearch(ASearchColumn: TcxTreeListColumn; ASearchingText: String; AExpandOnIncSearching: Boolean = True);
begin
cxTreeList.OptionsBehavior.IncSearch := True;
cxTreeList.OptionsBehavior.IncSearchItem := ASearchColumn;
cxTreeList.OptionsBehavior.ExpandOnIncSearch := AExpandOnIncSearching;
cxTreeList.SearchingText := ASearchingText;
repeat
if not cxTreeList.FindNext(True) then
begin
cxTreeList.CancelSearching;
Break;
end;
until cxTreeList.FocusedNode.Texts[ASearchColumn.ItemIndex] = ASearchingText
end;