From Appmethod Libraries
Jump to: navigation, search

Object Pascal

property OnFilter: TFilterEvent read FOnFilter write SetOnFilter;


__property Fmx::Searchbox::TFilterEvent OnFilter = {read=FOnFilter, write=SetOnFilter};


Type Visibility Source Unit Parent
event public
FMX.ListView TListViewBase


Occurs when a search box filters.

Write an event handler for OnFilter to set a custom search filter for TSearchBox.

The OnFilter event with the TFilterEvent type has the following parameters:

Parameter Description
<Sender> The object whose event handler is called.
<AFilter> The string being filtered among the different items (<AValue> parameter).
<AValue> The string of the item where the search of <AFilter> is being performed.
<Accept> Boolean parameter to use when there is a filter condition.

Use <Accept> to add a filter condition; if a value is filtered by the filter condition, <Accept> must be True.

For example, the below code snippet adds a custom filter to force the item (<AValue>) to start with the string being filtered (<AFilter>):

Object Pascal:

procedure TForm2.ListView1Filter(Sender: TObject; const AFilter, AValue: string;
  var Accept: Boolean);
  Accept :=  AValue.StartsWith(AFilter, True);


void __fastcall TForm1::ListView1Filter(TObject *Sender, const UnicodeString AFilter,
		  const UnicodeString AValue, bool &Accept)
	Accept = StartsStr(AFilter.LowerCase(), AValue.LowerCase());

Note: Enable the SearchVisible property to show the search box on top of your list view.

See Also