Using Delphi Seattle, I'm trying to get the hang of livebinding in our current project and have created a form with an externally filled TFDMemTable. The memTable is connected to a TGrid and to a TListbox. The grid displays all info like it should, but the listbox stays empty.
What am i doing wrong?
Code (simplified from actual situation, but still showing empty listbox):
unit Unit1;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, System.Rtti, FireDAC.Stan.Intf,
FireDAC.Stan.Option, FireDAC.Stan.Param, FireDAC.Stan.Error, FireDAC.DatS, FireDAC.Phys.Intf, FireDAC.DApt.Intf,
FireDAC.Stan.StorageBin, Data.Bind.EngExt, Fmx.Bind.DBEngExt, Fmx.Bind.Grid, System.Bindings.Outputs,
Fmx.Bind.Editors, Data.Bind.Components, Data.Bind.Grid, FMX.ListBox, Data.Bind.DBScope, Data.DB, FireDAC.Comp.DataSet,
FireDAC.Comp.Client, FMX.Layouts, FMX.Grid, FMX.Types, FMX.Controls, FMX.Controls.Presentation, FMX.StdCtrls,
FMX.Forms;
type
TForm1 = class(TForm)
fdmAccounts: TFDMemTable;
fdmAccountscode: TStringField;
fdmAccountsdesc: TStringField;
bsAccounts: TBindSourceDB;
Grid1: TGrid;
BindingsList1: TBindingsList;
ListBox1: TListBox;
LinkGridToDataSourcebsAccounts: TLinkGridToDataSource;
LinkFillControlToField1: TLinkFillControlToField;
procedure FormCreate(Sender: TObject);
private
FItemlist: TStringlist;
procedure Refreshlist(Sender: TObject);
procedure UpdateAccounts(afilter: string);
end;
var
Form1: TForm1;
implementation
{$R *.fmx}
procedure TForm1.UpdateAccounts(aFilter: string);
var
s: string;
begin
with fdmAccounts do
begin
EmptyDataSet;
for s in FItemList do
begin
if aFilter.IsEmpty or s.Contains(aFilter) then
InsertRecord([s, '']);
end;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
FItemlist := TStringList.Create;
FItemlist.Delimiter := ',';
Fitemlist.DelimitedText := 'item1, item2, ander item3, laatste item';
fdmAccounts.Open;
Refreshlist(nil);
end;
procedure TForm1.Refreshlist(Sender: TObject);
begin
UpdateAccounts('');
end;
end.
Livebinding definitions:
object BindingsList1: TBindingsList
Methods = <>
OutputConverters = <>
Left = 164
Top = 237
object LinkGridToDataSourcebsAccounts: TLinkGridToDataSource
Category = 'Quick Bindings'
DataSource = bsAccounts
GridControl = Grid1
Columns = <>
end
object LinkFillControlToField1: TLinkFillControlToField
Category = 'Quick Bindings'
Control = ListBox1
Track = True
FillDataSource = bsAccounts
FillDisplayFieldName = 'desc'
AutoFill = True
FillExpressions = <>
FillHeaderExpressions = <>
FillBreakGroups = <>
end
end
I aslo tried setting the FillExpression of the LinkFillControlToField1 to this:
FillExpressions = <
item
SourceMemberName = 'desc'
ControlMemberName = 'Text'
end>
But with the same result .. empty listbox