VCL.SearchBox Sample
This is a sample that shows the use of the TSearchBox control.
Contents
Location
You can find the SearchBox sample project at:
- Start | Programs | Embarcadero RAD Studio 10.2 Tokyo | Samples and then navigate to either:
Object Pascal\VCL\SearchBox
CPP\VCL\SearchBox
- Subversion Repository for Delphi: http://sourceforge.net/p/radstudiodemos/code/HEAD/tree/branches/RADStudio_Tokyo/Object%20Pascal/VCL/SearchBox
- Subversion Repository for C++: http://sourceforge.net/p/radstudiodemos/code/HEAD/tree/branches/RADStudio_Tokyo/CPP/VCL/SearchBox
Description
This application demonstrates the TSearchBox control and how to use the OnInvokeSearch event of TSearchBox.
The application uses the following controls:
SB
: The search box.lstLog
: The listbox for the feedabck messages.grpBiDiMode
: The radio buttons that allow you to change the BiDiMode.grpSearchIndicator
: The radio buttons that allow you to change the search indicatior icon.chkEnabled
: Enables or disables the search box.cbxVclStyles
: A combo box that allows you to change the style of the application. You can choose between any style that is active in the Application Appearance - Custom Styles options for this project.
How to Use the Sample
- Navigate to one of the locations given above and open:
- Delphi: SearchBox.dproj.
- C++: SearchBox.cbproj.
- Press F9 or choose Run > Run.
- Change the different options on the form and test the search box functionality. Type into the search box and press
Enter
or click the search indicator button.
Implementation
TSearchBoxForm
On initialization, the FormCreate
adds all the active styles to the cbxVclStyles
combo box.
- The application defines the following event handlers:
grpSearchIndicatorClick
: Changes the SearchIndicator type.cbxVclStylesChange
: Sets the style for the application.chkEnabledClick
: Enables or disables the search box.grpBiDiModeClick
: Changes the BiDiMode.SBInvokeSearch
: Responds to the OnInvokeSearch event of TSearchBox. Calls theLog
method and passes the input from the search box.
- The application also defines the following methods:
Log
: Adds the received text to the listbox.