Show: Delphi C++
Display Preferences

Tutorial: Using LiveBinding to Create a FireMonkey Application Without Code

From RAD Studio XE2
Jump to: navigation, search

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:

  1. Create a new project. Choose a FireMonkey HD Application for this example.
  2. Drag and drop a DataSource component and a ClientDataSet component onto the Form Designer.
  3. In the Object Inspector, connect the DataSource component to the ClientDataSet using the DataSource.DataSet property.
  4. 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.

    DSDBTutorial1.png

  5. 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.
  6. Set the Active property to True.
  7. Now you can simply bind each graphical control on the form to their appropriate field in the database.
    1. Select the Label component and then seek the LiveBindings property in the Object Inspector. Click the ProjectOptionsDownArrow2.jpg down-arrow in the value field, and select Link to DB Field.
    2. On the New DB Link dialog box, select Category.

      DSDBTutorial2.png

    3. Then select the edit box component and also bind it to the Category item in the list.
    4. Link the memo component to the Notes item.
    5. Bind the image control component to the Graphic item.
    6. Finally, link the bind navigator to the binding scope by assigning the BindScope property to BindScopeDB1.
  8. 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:

    DSDBTutorial3.png

  9. At this point, you can run the application (either choose Run > Run or press F9).
  10. 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:

DSDBTutorial4.png

See Also

Sample Application

Personal tools
Previous Versions
In other languages