This sample demonstrates how to use the TComboBox component to customize and invoke an item picker.
You can find the CustomPicker sample project at:
-
Start | Programs | Embarcadero RAD Studio Rio | Samples and then navigate to:
-
Object Pascal\Mobile Snippets\CustomPicker
-
CPP\Mobile Snippets\CustomPicker
-
GitHub Repository:
-
C++:https://github.com/Embarcadero/RADStudio10.4Demos/tree/master/CPP/Mobile%20Snippets/CustomPicker
The CustomPicker sample demonstrates how to use an item picker on Android and iOS devices. The sample uses TComboBox to customize the options of the picker and to allow the user to pick an item and display the text of the selected item on a label.
- Navigate to one of the locations given above and open:
- Delphi: CustomPicker.dproj.
- C++: CustomPicker.cbproj.
- Select the target platform, iOS and Android supported.
- Press F9 or choose Run > Run.
- Interact with the sample:
- Click or tap the TComboBox control. See how it displays the native picker that allows you to select an item.
- Select an item.
- The sample displays the text of the selected item on a label.
File in Delphi | File in C++ | Contains |
---|---|---|
CustomPicker.dproj | CustomPicker.cbproj | The project itself. |
uMain.fmx | uMain.fmx | The main form where the components are located. |
uMain.pas | CustomPickerPCH.h, CustomPicker.cpp | Used to define and implement the sample. |
Information.txt | Information.txt | Further information about the sample. |
TCustomPickerForm is the main form that represents the main window of the sample. It contains the following components:
-
A TListBox object containing two TListBoxItems.
-
The first TListBoxItem contains a TComboBox object with four TListBoxItems:
-
TListBoxItem1 called Item One.
-
TListBoxItem2 called Item Two.
-
TListBoxItem3 called Item Three.
-
TListBoxItem4 called Item Four.
-
The second TListBoxItem is empty.
- The sample uses TComboBox to display a list of items and select an item from it.
- The sample uses TListBox to locate the TComboBox on the first TListBoxItem and to display the selected item on the second TListBoxItem. When you run the application, there are two TListBoxItems. In the first TListBoxItem, click on the TComboBox next to Pick an Item. Then, the sample displays an item picker that allows you to select one of the four items. When you select an item, an OnChange event displays the text of this item in the second TListBoxItem.