FMX.ListView.TListViewBase.OnSearchChange

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

property OnSearchChange: TNotifyEvent read FOnSearchChange write FOnSearchChange;

C++

__property System::Classes::TNotifyEvent OnSearchChange = {read=FOnSearchChange, write=FOnSearchChange};

Properties

Type Visibility Source Unit Parent
event public
FMX.ListView.pas
FMX.ListView.hpp
FMX.ListView TListViewBase

Description

Occurs when the search box in a list view loses the focus and its content has changed since it gained the focus. This event exposes the OnChange event of the TSearchBox that implements the search box of a list view.

For example, the code snippet below updates the text in a status bar on this event to show the number of items left in the list after the specified filter is applied:

Delphi:

procedure TMainForm.ListViewSearchChange(Sender: TObject);
var
 I: Integer;
 SearchBox: TSearchBox;
 List: TListView;
begin
 List := Sender as TListView;
 for I := 0 to List.Controls.Count-1 do
 if List.Controls[I].ClassType = TSearchBox then
 begin
 SearchBox := TSearchBox(List.Controls[I]);
 Break;
 end;
 StatusBar.Text := IntToStr(List.Items.Count) + ' list items match ' + QuotedStr(SearchBox.Text) + '.';
end;

C++:

void __fastcall TMainForm::ListViewSearchChange(TObject *Sender)
{
 TSearchBox* searchBox;
 TListView* list = reinterpret_cast<TListView*>(Sender);
 for (int i = 0; i < list->Controls->Count; i++) {
 searchBox = dynamic_cast<TSearchBox*>(list->Controls->Items[i]);
 if (searchBox) break;
 }
 MainForm->StatusBar->Text = UnicodeString(list->Items->Count) + " list items match " + QuotedStr(searchBox->Text) + ".";
}

See Also

Retrieved from "https://docwiki.embarcadero.com/Libraries/Tokyo/e/index.php?title=FMX.ListView.TListViewBase.OnSearchChange&oldid=733933"