FranzB 0 Posted September 28, 2020 (edited) we will execute the opposite of the instructions given here http://docwiki.embarcadero.com/RADStudio/Sydney/en/LiveBindings_in_RAD_Studio , create a livebindings application , show a query in a stringgrid, without using the live bindings designer my code goes like this , the issue : the code compiles, I guess open query also is functional but the stringgrid remains empty var BindSourceDB1: TBindSourceDB; LinkGridToDataSourceBindSourceDB1: TLinkGridToDataSource; begin aServername := edt_Servername.Text; adatabasename := edt_databasename.Text; ConnecttoDatabase(aServername, adatabasename, aConnection); // a subfunction aQuery.SQL.Text := 'select * from MyTable '; aQuery.Open; // guess fine, because on a VCL application the data are displayed BindSourceDB1 := TBindSourceDB.Create(Self); BindSourceDB1.DataSet := aQuery; LinkGridToDataSourceBindSourceDB1 := TLinkGridToDataSource.Create(Self); LinkGridToDataSourceBindSourceDB1.DataSource := BindSourceDB1; LinkGridToDataSourceBindSourceDB1.GridControl := strngrd_Objecttable; end; Edited September 28, 2020 by FranzB Share this post Link to post
Jacek Laskowski 57 Posted September 28, 2020 I don't know the answer to the question, but it may be useful: https://github.com/malcolmgroves/FluentLiveBindings 3 1 Share this post Link to post
Rollo62 536 Posted September 28, 2020 Maybe thats helpful too, from Stephen Ball's nice video lectures. Share this post Link to post
Serge_G 87 Posted September 30, 2020 (edited) Yes FluentLiveBindings should work, and so easy to write BindingsList1.BindGrid(Grid1).ToBindSource(BindSourceDB1); But no CustomFormat can be used (perhaps I don't know how, or further development ?) My code for runtime linking var ABindGrid : TBindGridLink; begin ABindGrid:=TBindGridLink.Create(self); ABindGrid.ControlComponent := Grid1; ABindGrid.SourceComponent := BindSourceDB1; // synch with ABindGrid.PosControlExpressions.AddExpression do begin ControlExpression := 'Selected'; SourceExpression := 'Math_Max(0,DBUtils_ActiveRecord(Self))'; end; with ABindGrid.PosSourceExpressions.AddExpression do begin ControlExpression := 'Math_Max(1,Selected+1)'; SourceExpression := 'DBUtils_ValidRecNo(Self)'; end; // columns with ABindGrid.ColumnExpressions.AddExpression do begin ColumnName := 'Column1'; ColumnIndex := 0; SourceMemberName := 'SS_NUMBER'; // field format '0 000 000 00' (a crazy one ;-) just for test) with FormatCellExpressions.AddExpression do begin ControlExpression := 'Data'; SourceExpression := 'DisplayText'; // I kept Display text, but 10.4.1 don't need end; end; with ABindGrid.ColumnExpressions.AddExpression do begin ColumnName := 'Column2'; ColumnIndex := 1; SourceMemberName := 'FIRST_NAME'; With FormatCellExpressions.AddExpression do begin ControlExpression := 'Data'; SourceExpression := 'Value+'#39' '#39'+Dataset.LAST_NAME.text'; end; end; Regret, I am unable to use a "with TBindGridLink.Create(Self) do ...." form Edited September 30, 2020 by Serge_G Share this post Link to post
FranzB 0 Posted September 30, 2020 (edited) i like to use https://github.com/malcolmgroves/FluentLiveBindings var BindSourceDB1: TBindSourceDB; begin aServername := edt_Servername.Text; adatabasename := edt_databasename.Text; ConnecttoDatabase(aServername, adatabasename, aConnection); aQuery.SQL.Text := 'select * from Mytab'; aQuery.Active := True; BindSourceDB1 := TBindSourceDB.Create(Self); BindSourceDB1.DataSet := aQuery; BindingsList1.BindGrid(grd_objecttab).ToBindSource(BindSourceDB1); but run time error msg is now like below , any idea for this error ? Edited September 30, 2020 by FranzB Share this post Link to post
Serge_G 87 Posted October 1, 2020 Well, , I only test Fluent Livebindings with a TGrid, not TStringGrid, but demo included in the package is with a stringgrid, so I don't see anything except a missing unit in your form. My tests are somewhere a little not objectives in the way I put on the same form a grid linked (TBindGridLink) with the visual livebindings editor and another with Fluent (raising the fact this last is not a WYWSSEWYG method) unit so all the units were added. Share this post Link to post
Dirk Janssens 0 Posted May 5, 2022 (edited) A little late, but for others with the same problem... I found (one of the possible) causes : In the uses clause Fmx.Bind.Grid was missing. No errors if it's not there, just not working (!) kind regards Dirk Janssens. Edited May 5, 2022 by Dirk Janssens Share this post Link to post