This sample illustrates how to use LiveBindings to populate a list box with the items gathered from various collections, using a TBindList type of LiveBinding.
Note: Instructions for constructing this sample are given in Tutorial: Creating Collection Lists Using LiveBindings.
You can find the SurfSpotFinderApp sample project at:
- Start | Programs | Embarcadero RAD Studio Alexandria | Samples and navigate to:
Object Pascal\Multi-Device Samples\User Interface\ListCollections
- Subversion Repository:
- You can find Delphi code samples in GitHub Repositories. Search by name into the samples repositories according to your RAD Studio version.
The sample application uses several visual objects that are bound via TBindList to the list box. A combo box holds a series of items describing various collections you can choose from when populating the list box.
The Control Component and Control Expression fields are not editable and they specify the control component (ListBox1) and the control expression.
The Source Component field is also not editable and it specifies the source component, which varies each time you select another collection type from the combo box.
The Source Expression field is editable and allows typing in the binding expression used to gather information from the source component. This binding expression also supports conversion methods such as ToStr to convert from numbers to strings.
Each time you press the Fill button (or Auto Fill is selected), the list box is populated with 100 items, generated at run time, for the collection specified through the Collection combo box.
How to Use the Sample
- Navigate to the location given above, and open ListCollectionsSampleProject.dproj.
- Press F9 or choose Run > Run.
List Collections Demo represents the main window of the sample. It contains the following components:
- Two TButton objects
- Four TEdit objects
- Five TLabel objects
- Three TCheckBox objects
- A TComboBox
- A TListBox
- A TBindingsList
- A TBindScope
- A TBindList
- The SampleCollections.pas unit implements the additional supported collections of elements that will be exported to the List Box by means of LiveBindings.