Tutorial: Using LiveBinding to Create a FireMonkey Application Without Code

From Appmethod Topics
Jump to: navigation, search

Go Up to Tutorials#LiveBindings

Go Up to LiveBindings in Appmethod

LiveBindings 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 Appmethod | Samples and also available with the Samples on SourceForge at: Appmethod Demo Code. A code example that uses a similar database (DBDEMOS) is located at FishFact (Object Pascal) example.

Follow these steps to build a database application using LiveBinding:

  1. Create a new project. Choose a HD FireMonkey Application for this example.
  2. Drag and drop a ClientDataSet component onto the Form Designer.
  3. 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 TBindNavigator control. Optionally, you can add a Close button.

    At this point, your application should look like the following image.


  4. 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.
  5. Set the Active property to True.
  6. Now you can simply bind each graphical control on the form to its appropriate field in the database.
    1. Select the Label component and right-click it. Then select the LiveBindings Wizard... property in the context menu.


    2. On the LiveBindings Wizard, select Link a property of component "Label1" with a field.
    3. Select the Label1 component and the Text property.


    4. Select the ClientDataSet1 component.


    5. Select the Species Name field and click Finish to complete the LiveBinding.


  7. Repeat the steps above to connect the rest of the controls on the forms as following:
    1. Bind the edit box component to the Category field.
    2. Bind the memo component to the Notes field.
    3. Bind the image component to the Graphic field.
  8. Finally, link the bind navigator to the binding source by assigning the BindSource property to BindSourceDB1.
  9. You can see that two new components, BindSourceDB1 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 image.


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


See Also

Sample Application