XE3 Visual LiveBindings: bi-directional connection between TSpinBox and TTrackBar (FireMonkey)
I am using Delphi XE3 Service Pack 1 (SP1). I created a Desktop FireMonkey app and dropped the TSpinBox and TTrackBar in the main form. Now I have connected the TSpinBox and TTrackBar "Value" property using Visual Livebindings. The IDE automatically created a "TLinkControlToProperty" to connect them. When I move the slider to the TTrackBar, the values ββin the TSpinBox change. But when I change the value in the TSpinBox, the TTrackBar value is not updated.
How can I change this to a bi-directional connection using LiveBindings? My goal is to change the "Value" property of the TTrackBar when the "Value" TSpinBox changes. Also, I am interested in a solution that does not use the OnChange event for the "TSpinBox". Is this possible without calling the child "TSpinBox"?
source to share
You will need to add a binding via the Bindinglist defining Source and Destination, set the Direction to dirBiDirectional and add the 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;
What can be reduced to
procedure TForm1.OneChangeEventForAllControlsUsingBindinglist1(Sender: TObject);
begin
BindingsList1.Notify(Sender, '');
end;
source to share