3
votes

I am using Delphi XE3 with SP1. I have created a FireMonkey Desktop Application and dropped a TSpinBox and a TTrackBar on the main form. I have now connected the "Value" property of the TSpinBox and the TTrackBar using Visual Livebindings. The IDE has automatically created a "TLinkControlToProperty" to connect them. When I move the slider on the TTrackBar, the values in the TSpinBox change. But when I change the value in the TSpinBox, the value of the TTrackBar does not get updated.

How can I change this to a bidirectional connection using LiveBindings? My aim is to change the "Value" property of the TTrackBar, when the "Value" of the TSpinBox changes. Furthermore, I am interested in a solution that does not use the "OnChange" event of the "TSpinBox". Is this possible without deriving a descendant of "TSpinBox"?

1

1 Answers

3
votes

You will have to add the Binding via Bindinglist, defining Source and Destination, set Direction to dirBiDirectional and add following code to your source:

procedure TForm1.SpinBox1Change(Sender: TObject);
begin
 BindingsList1.Notify(Sender, '');
end;

procedure TForm1.TrackBar1Change(Sender: TObject);
begin
 BindingsList1.Notify(Sender, '');
end;

Which can be reduced to

procedure TForm1.OneChangeEventForAllControlsUsingBindinglist1(Sender: TObject);
begin
 BindingsList1.Notify(Sender, '');
end;

enter image description here