VCL.SearchBox Sample

From RAD Studio Code Examples
Jump to: navigation, search

This is a sample that shows the use of the TSearchBox control.

Location

You can find the SearchBox sample project at:

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

  1. Navigate to one of the locations given above and open:
    • Delphi: SearchBox.dproj.
    • C++: SearchBox.cbproj.
  2. Press F9 or choose Run > Run.
  3. 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 the Log method and passes the input from the search box.
  • The application also defines the following methods:
    • Log: Adds the received text to the listbox.

Uses

See Also