FMX.ListView.TListViewBase.OnFilter
Object Pascal
property OnFilter: TFilterEvent read FOnFilter write SetOnFilter;
C++
__property Fmx::Searchbox::TFilterEvent OnFilter = {read=FOnFilter, write=SetOnFilter};
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
event | public | FMX.ListView.pas FMX.ListView.hpp |
FMX.ListView | TListViewBase |
Description
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 |
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);
begin
Accept := AValue.StartsWith(AFilter, True);
end;
C++:
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.