0
votes

Delphi 10.4

I have an issue bidirectional Tstrings binding. I have a simple app with 2 controls and a bind source. I am trying to bind bidirectionally a TStrings property of an object to to a TMemo control. I am using a TPrototypeBindSource with a TObjectBindSourceAdapter as the bind source adapter.

I have the lines property on the TPrototypeBindSource set to a ftTStrings fieldtype

enter image description here

TFoo is defined as;

  TFoo = class  (TObject)
  private
    Fname: string;
    flines: TStrings;
  published
    constructor Create;
    destructor destroy; override;
    property name: string read Fname write Fname;
    property lines: Tstrings read Flines write Flines;
  end;

The Adapter is set with the on create event

procedure TForm1.PrototypeBindSource1CreateAdapter(Sender: TObject; var ABindSourceAdapter: TBindSourceAdapter);
begin
  ABindSourceAdapter := TObjectBindSourceAdapter<TFoo>.Create(Self, GetFoo, False);
end;

Using live bindings I have the

PrototypeBindSource name fielddef <---> edit text field. PrototypeBindSource lines fielddef <---> memo text field.

enter image description here

All is good when you are reading or updating the name <-> edit control and when setting the memo text field. It recognises the lines field in the TPrototypeBindSource as being a TStrings.

However, when I change the text in the memo and go to post it back to the TPrototypeBindSource I get this exception

EBindConverterError : unable to cast or find converters between types string and TObject

There is a TStrings to string and string to TStrings converters registered. But there seems a disconnect between the TString in the object and the adapter as it cannot seem to see its type.

Have I missed something or is the RTL got issues?