Tutorial: Using LiveBinding to Create a FireMonkey Application Without Code
Go Up to Tutorials
Go Up to LiveBindings in RAD Studio
LiveBinding is a data binding technology introduced in the XE2 release that helps you develop database applications. This tutorial demonstrates how to build a small yet powerful database application using LiveBinding. You can do almost everything here with a few simple mouse clicks; no coding is required.
This tutorial uses the biolife.cds database, typically installed in the Samples directory at Start | Programs | Embarcadero RAD Studio | Samples and also available with the Samples on SourceForge at: RAD Studio Demo Code. A code example that uses a similar database (DBDEMOS) is located at FishFact (Delphi) example.
Follow these steps to build a database application using LiveBinding:
- Create a new project. Choose a FireMonkey HD Application for this example.
- Drag and drop a DataSource component and a ClientDataSet component onto the Form Designer.
- In the Object Inspector, connect the DataSource component to the ClientDataSet using the DataSource.DataSet property.
- Add the following controls to the form: a label, an edit box, a memo, and an image control component. To be able to cycle through the records of the database you chose to open, you need an additional BindNavigator control. Optionally, you can add a Close button.
At this point, your application should look like the following image.
- Before using LiveBinding, you need to specify a database file for the ClientDataSet component. Use the FileName property to specify a ClientDataSet (*.cds) file, and select the biolife.cds file.
- Set the Active property to True.
- Now you can simply bind each graphical control on the form to their appropriate field in the database.
- Select the Label component and then seek the LiveBindings property in the Object Inspector. Click the down-arrow in the value field, and select Link to DB Field.
- On the New DB Link dialog box, select Category.
- Then select the edit box component and also bind it to the Category item in the list.
- Link the memo component to the Notes item.
- Bind the image control component to the Graphic item.
- Finally, link the bind navigator to the binding scope by assigning the BindScope property to BindScopeDB1.
- You can see that two new components, BindScopeDB1 and BindingsList1, have been added to the form. These components are not visual and are part of the LiveBinding engine. (To manually alter the bindings in the BindingsList1 component, double-click it. But that is not the purpose of this tutorial.)
Now your application should look like the following picture:
- At this point, you can run the application (either choose Run > Run or press
- After the application is running, you can cycle through the database records, add a record, delete a record, or update the database.
The completed running application:
- LiveBindings in RAD Studio
- Developing Database Applications
- Developing DataSnap Applications
- FireMonkey HD Application
- The New DB Link dialog box
- Tutorial: Using InterBase Express to Create an Application Without Code
- Object Inspector