Search code examples
idedelphi-11-alexandria

How to find FMX TSearchBox


I have a multi-device FMX project in Delphi 11. I would like to add a search box to a form, but I cannot find a TSearchBox component in the tool palette. The docs confirm that a TSearchBox component exists. I'm using the WedgewoodLight style (from GetIt) which contains search box related styles (searchboxstyle, searcheditbutton, searchtoolbutton, searchtoolbuttonbordered) but when I place an TEdit on a form none of those styles is displayed in the StyleLookup options for the edit.

The Controls sample app contains a TSearchBox component in a design view. It seems I can copy it to the clipboard but I cannot paste it into my project.

Is there a way to visually add a TSearchBox to my project?

Thanks


Solution

  • The TSearchBox in the MobileControls sample is a child component of the TListBox. You can add it by right clicking on a TListBox and choosing Add ItemTSearchBox.

    Adding a TSearchBox to the TListBox

    If you look in the FMX.SearchBox unit, where TSearchBox is defined, you will see it implements the IListBoxHeaderTrait interface. It looks like it should work outside a TListBox, but you could easily create your own version too of you look at the code.

    Interestingly the TSearchBox is missing from the ListBox's Item Editor dialog, as are about half of the other items...

    TListBox Items Editor