C++ComponentsDatabaseIntroduction to C++Language FeatureLearn C++

Everything You Need To Know About C++ Data Bindings

Everything You Need To Know About C++ Data Bindings

In this post, you’ll get answers to these questions:

  • What are LiveBindings?
  • How can I create LiveBindings in C++ Builder applications?
  • How can I use LiveBindings in applications?
  • What are the Livebindings Visual Components?
  • Are there any official LiveBindings samples?
  • Can I have more information about LiveBindings API Reference?
  • How Can I Synchronize Data through LiveBindings?
  • How to Create LiveBindings-Enabled Components?
  • Which Editors can be used related to LiveBindings Editors?
  • Can I Have More Information about the LiveBindings Action Lists?

By learning more about c++ data binding, it will help you to easily build C++ applications with the use of a C++ IDE.

Does C++ Builder come with a LiveBindings feature?

C++ Builder comes with a LiveBindings feature which is a data-binding functionality supported by both the VCL and FireMonkey FMX frameworks in RAD Studio. LiveBindings is an expression-based framework, which means it uses bindings expressions to bind objects to other objects or to dataset fields.

There is an official DockWiki web page by Embarcadero about the LiveBindings here, please check this official link if you want to see the latest changes.

What are LiveBindings in C++?


LiveBindings are based on relational expressions, called binding expressions, that can be either unidirectional or bidirectional. LiveBindings also has a concept of control objects and source objects. By means of binding expressions, any object can be bound to any other object, simply by defining a binding expression involving one or more properties of the objects you want to bind together. For example, you can bind a TEdit control to a TLabel so that when the text changes in the edit box, the text of the label is automatically adjusted to the value evaluated by your binding expression. Another example is binding a track bar control to a progress bar so that the progress rises or lowers as you move the track bar.

We can connect to dataset fields, alter one or more properties of different objects, and so on. Because LiveBindings propagate, we can even alter properties of objects that are connected to other objects that are bound to a control object.

How do I create LiveBindings?

The primary way to create bindings is using the LiveBindings Designer as we described above. The Designer can only create QuickBindings components. The graph shows the bindings of other components (such as TBindLink), but you cannot move the end points as you can with QuickBinding components.

There is a second way to create such bindings, using the LiveBindings Wizard. It also only creates QuickBinding components. The LiveBindings Designer uses QuickBindings to create this type of binding (which is also reflected in the wizard). You can use them to:

  • Link a control such as TEdit to a field in a data source
  • Link a control such as a TGrid to a data source
  • Link a control such as TEdit to a component property (such a TLabel.Text)
  • Link a component property to a field in a data source

A control can only link to one end point. So if a TEdit is linked to a field and you try to link the TEdit to a component property, the link to the field will be deleted. Also, a component property can link to one end point. Data sources and data source members can link to multiple end points. For example, a field can be linked to a TEdit and also to a TLabel. There would be two binding components involved.

Even though the LiveBindings Designer does not allow a control to link to two other component properties, it is possible to get this effect by linking the control and the component properties to a single field. You can use the TPrototypeBindSource component to create a field for this purpose.

The term Link used in LiveBindings and API documentation indicates that the bindings acknowledge changes made by the user and automatically update controls and data sources to respond to user input.

How do I use LiveBindings in C++ Builder?

You can use LiveBindings in VCL Forms Applications and FireMonkey applications by using either the LiveBindings Designer or the LiveBindings Wizard. Note that you can invoke the wizard either through the Object Inspector or by right-clicking individual components placed on the form (but only if the wizard is previously enabled from the Tools > Options > LiveBindings dialog box).

Refer to the Creating LiveBindingsNew LiveBinding or LiveBindings Wizard topic for a quick overview on how to create LiveBindings in RAD Studio. And see Tutorial: Using LiveBinding Programatically for instructions on creating LiveBindings programmatically,

Where can I find the LiveBindings visual components?

The LiveBindings engine is a run-time feature, but a number of visual components are present in the Tool Palette, to help you create live bindings between components at design time. Sometimes you may also create bindings in a visual manner, using the LiveBindings Wizard or the LiveBindings Designer.

If you browse the Tool Palette, in the LiveBindings or LiveBindings Misc tabs, you can drag and drop the following components to a form (either VCL or FireMonkey).

TBindSourceDB Is used for creating bindings to databases.
TPrototypeBindSource Provides a data source for generating sample data that you can use to get started when you do not already have data to start with. Later you can replace this data source with some real data.
TBindSourceDBX Is used for creating binding to databases using the DBX framework.
TParamsAdapter Is used for binding visual controls to DBX command parameters.
TBindNavigator Is used for cycling through records in a dataset when developing FMX or VCL applications.
TBindingsList Is used for holding binding lists.
TDataGeneratorAdapter Is an adapter for data generators.
TAdapterBindSource Is used for working with non-database data. The adapter property is used to connect the data source to non-database data, such as a generic collection of objects.

Tip: When you use the LiveBindings Designer to create live bindings between components, the appropriate LiveBindings component (TBindingsList) is automatically placed on the form. This component holds a list of all bindings available in your application. See the Bindings Lists topic for more information about binding lists.

Are there Any Official LiveBindings C++ samples?

There are a number of LiveBindings sample applications shipped along with RAD Studio that you can find by clicking Start | Programs | Embarcadero RAD Studio Alexandria | Samples. The main folder of interest is Object Pascal\LiveBinding. There is another LiveBinding sample in the folder Object Pascal\FireMonkey Desktop\ListCollections, which is described in FMX.ListCollections Sample. These samples are listed in the following table, divided by their corresponding category (FMX or VCL). Some of the sample applications are available for both FMX and VCL while others are available for only one of these two categories.

Tip: For information on how to update the Samples directory to the latest SVN version, please refer to the Sample help topic.

FMX LiveBindings SamplesVCL LiveBindings Samples

These samples show you in detail how to build enhanced applications using LiveBindings.

The source for the LiveBindings samples in your product installation are checked into a public Subversion repository that can be found on the .

Is there further information about the LiveBindings API?

The following units are part of the LiveBindings engine. The documentation in their appropriate help topics contains information regarding LiveBindings API usage.

Unit NameContains
System.Bindings.CustomScopeCustom scope-related classes
System.Bindings.CustomWrapperCustom wrapper-related classes
System.Bindings.EvalProtocolInterfaces used by the engine for the wrappers, scopes, and other internal structures
System.Bindings.ExpressionBinding expression-related classes
System.Bindings.ExpressionDefaultsDefault behavior for binding expressions
System.Bindings.FactoriesFactories for expressions, managers, and scopes
System.Bindings.HelperTools for programmatic creation of binding expressions and for notifications
System.Bindings.ManagerBinding manager-related implementations
System.Bindings.ManagerDefaultsDefault behavior for binding managers
System.Bindings.MethodsControl of methods that can be used in the script
System.Bindings.OutputsTools for control of expression outputs
Data.BindContains units with implementations for the LiveBindings components

Hint: When using C++Builder to develop console applications that make use of LiveBindings, you have to explicitly instruct the C++ compiler to generate RTTI information for the classes in your project. To do this, add the #pragma explicit_rtti methods() directive at the beginning of your project, as shown in the Using LiveBinding Programatically tutorial. For more information regarding the #pragma explicit_rtti methods() directive, please refer to the Pragma explicit rtti help topic.

How can I synchronize data through LiveBindings?

Using LiveBindings in RAD Studio you can synchronize various data for instance a list box control with a string grid, provided that both contain the same data. Refer to the Synchronizing Data through LiveBindings topic in order to learn how to synchronize data through the Synch and * properties of certain components within the LiveBindings Designer.

How can I create my own LiveBindings-Enabled components?

There are two requirements to enable a simple control like TTrackBar for LiveBindings usage. The first requirement is that the control must implement observer support. LiveBindings depends on observers to subscribe to control notifications. The second requirement is to register the control value name (for instance: Position for a TTrackBar component). The control value name is used by LiveBindings components to generate expressions which get and set the control value.

For more information on how to create LiveBindings-enabled components, read the Creating LiveBindings-Enabled Components tutorial.

Which editors are available for LiveBindings?

The primary visual editor is RAD Studio meanwhile C++ Builder, Delphi IDE. In addition to this the following are editors in RAD Studio that are related to LiveBindings:

See also LiveBindings Dialog Boxes.

Where can I find more information about using LiveBindings with Action Lists?

See this link: LiveBindings and Action Lists.

All the text above is from the DocWiki of Embarcadero although we made few changes for this post. Note that in addition to these, we have added very simple VCL and FMX examples to create your first VisualBindings. Please check these posts from the LearnCPlusPlus.org

C++ Builder is the easiest and fastest C and C++ IDE for building simple or professional applications on the Windows, MacOS, iOS & Android operating systems. It is also easy for beginners to learn with its wide range of samples, tutorials, help files, and LSP support for code. RAD Studio’s C++ Builder version comes with the award-winning VCL framework for high-performance native Windows apps and the powerful FireMonkey (FMX) framework for cross-platform UIs.

There is a free C++ Builder Community Edition for students, beginners, and startups; it can be downloaded from here. For professional developers, there are Professional, Architect, or Enterprise versions of C++ Builder and there is a trial version you can download from here.

Oh hi there 👋
It’s nice to meet you.

Sign up to receive awesome C++ content in your inbox, every day.

We don’t spam! Read our privacy policy for more info.

Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial

Free C++Builder Community Edition

About author

Dr. Yilmaz Yoru has 35+ years of coding with more than 30+ programming languages, mostly C++ on Windows, Android, Mac-OS, iOS, Linux, and some other operating systems. He graduated and received his MSc and PhD degrees from the Department of Mechanical Engineering of Eskisehir Osmangazi University. He is the founder and CEO of ESENJA LLC Company. His interests are Programming, Thermodynamics, Fluid Mechanics, Artificial Intelligence, 2D & 3D Designs, and high-end innovations.
Related posts
Artificial Intelligence TechC++C++11C++14C++17Language FeatureLearn C++

Learn How To Read The WAV Waveform Audio File Format In C++

C++C++11Learn C++

What Is Assignment Operator Overloading?

C++C++11Introduction to C++Learn C++Syntax

Full List Of Features In C++ 11

C++C++11C++14C++17C++20Introduction to C++Learn C++Syntax

How To Use Basic Methods Of Strings In C++?