Delphi Everything You Need To Know About C++ Data Bindings

FireWind

Свой
Регистрация
2 Дек 2005
Сообщения
1,957
Реакции
1,203
Credits
4,034
Everything You Need To Know About C++ Data Bindings
By Yilmaz Yoru October 4, 2021

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 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 in Action Lists? Let’s answer these questions:

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 Для просмотра ссылки Войди или Зарегистрируйся, please check this official link if you want to see the latest changes.

What are LiveBindings in C++?​

1633330029871.png
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 Для просмотра ссылки Войди или Зарегистрируйся as we described above. The Designer can only create QuickBindings components. The graph shows the bindings of other components (such as Для просмотра ссылки Войди или Зарегистрируйся), but you cannot move the end points as you can with QuickBinding components.

There is a second way to create such bindings, using the Для просмотра ссылки Войди или Зарегистрируйся. It also only creates QuickBinding components. The LiveBindings Designer uses QuickBindings to create this type of binding (which is also reflected in the Для просмотра ссылки Войди или Зарегистрируйся). 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 Для просмотра ссылки Войди или Зарегистрируйся is linked to a field and you try to link the Для просмотра ссылки Войди или Зарегистрируйся 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 Для просмотра ссылки Войди или Зарегистрируйся and also to a Для просмотра ссылки Войди или Зарегистрируйся. 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 Для просмотра ссылки Войди или Зарегистрируйся 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 Для просмотра ссылки Войди или Зарегистрируйся applications by using either the Для просмотра ссылки Войди или Зарегистрируйся or the Для просмотра ссылки Войди или Зарегистрируйся. Note that you can invoke the wizard either through the Для просмотра ссылки Войди или Зарегистрируйся 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 Для просмотра ссылки Войди или Зарегистрируйся, Для просмотра ссылки Войди или Зарегистрируйся or Для просмотра ссылки Войди или Зарегистрируйся topic for a quick overview on how to create LiveBindings in RAD Studio. And see Для просмотра ссылки Войди или Зарегистрируйся 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 Для просмотра ссылки Войди или Зарегистрируйся, to help you Для просмотра ссылки Войди или Зарегистрируйся at design time. Sometimes you may also create bindings in a visual manner, using the Для просмотра ссылки Войди или Зарегистрируйся or the Для просмотра ссылки Войди или Зарегистрируйся.

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).

Для просмотра ссылки Войди или Зарегистрируйся Is used for creating bindings to databases.
Для просмотра ссылки Войди или Зарегистрируйся 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.
Для просмотра ссылки Войди или Зарегистрируйся Is used for creating binding to databases using the Для просмотра ссылки Войди или Зарегистрируйся.
Для просмотра ссылки Войди или Зарегистрируйся Is used for binding Для просмотра ссылки Войди или Зарегистрируйся to Для просмотра ссылки Войди или ЗарегистрируйсяДля просмотра ссылки Войди или Зарегистрируйся command parameters.
Для просмотра ссылки Войди или Зарегистрируйся Is used for cycling through records in a dataset when developing FMX or VCL applications.
Для просмотра ссылки Войди или ЗарегистрируйсяДля просмотра ссылки Войди или ЗарегистрируйсяДля просмотра ссылки Войди или Зарегистрируйся Is used for holding Для просмотра ссылки Войди или Зарегистрируйся.
Для просмотра ссылки Войди или Зарегистрируйся Is an adapter for data generators.
Для просмотра ссылки Войди или Зарегистрируйся 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 Для просмотра ссылки Войди или Зарегистрируйся to Для просмотра ссылки Войди или Зарегистрируйся, 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 Для просмотра ссылки Войди или Зарегистрируйся topic for more information about binding lists.
 

FireWind

Свой
Регистрация
2 Дек 2005
Сообщения
1,957
Реакции
1,203
Credits
4,034

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 Для просмотра ссылки Войди или Зарегистрируйся. These samples are listed in the following table, divided by their corresponding category (Для просмотра ссылки Войди или Зарегистрируйся or Для просмотра ссылки Войди или Зарегистрируйся). 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 Для просмотра ссылки Войди или Зарегистрируйся help topic.

FMX LiveBindings SamplesVCL LiveBindings Samples
BindGridLinkFMXProjectBindGridLinkVCLProject
BindLinkFMXProjectBindLinkVCLProject
N/AOneOfEachBindCompVCL
ListCollectionsSampleProjectN/A
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
Для просмотра ссылки Войди или ЗарегистрируйсяCustom scope-related classes
Для просмотра ссылки Войди или ЗарегистрируйсяCustom wrapper-related classes
Для просмотра ссылки Войди или ЗарегистрируйсяInterfaces used by the engine for the wrappers, scopes, and other internal structures
Для просмотра ссылки Войди или ЗарегистрируйсяBinding expression-related classes
Для просмотра ссылки Войди или ЗарегистрируйсяDefault behavior for binding expressions
Для просмотра ссылки Войди или ЗарегистрируйсяFactories for expressions, managers, and scopes
Для просмотра ссылки Войди или ЗарегистрируйсяTools for programmatic creation of binding expressions and for notifications
Для просмотра ссылки Войди или ЗарегистрируйсяBinding manager-related implementations
Для просмотра ссылки Войди или ЗарегистрируйсяDefault behavior for binding managers
Для просмотра ссылки Войди или ЗарегистрируйсяControl of methods that can be used in the script
Для просмотра ссылки Войди или ЗарегистрируйсяTools for control of expression outputs
Для просмотра ссылки Войди или ЗарегистрируйсяContains 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 Для просмотра ссылки Войди или Зарегистрируйся 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 Для просмотра ссылки Войди или Зарегистрируйся. For more information regarding the #pragma explicit_rtti methods() directive, please refer to the Для просмотра ссылки Войди или Зарегистрируйся 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 Для просмотра ссылки Войди или Зарегистрируйся topic in order to learn how to synchronize data through the Synch and * properties of certain components within the Для просмотра ссылки Войди или Зарегистрируйся.

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 Для просмотра ссылки Войди или Зарегистрируйся 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 Для просмотра ссылки Войди или Зарегистрируйся.

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

See this link: Для просмотра ссылки Войди или Зарегистрируйся.