Below is a minimal FMX LiveBindings project written & compiled with Delphi Seattle which (I hope!) shows a long-standing issue with LiveBindings which goes back to the first time I attempted to use them in the XE4 era.
I've included the code and a .DFM extract below for the avoidance of any doubt as to how things are set up.
In Seattle, when I run the app, what I see in the StringGrid is the row with ID = 1 followed by two copies of row ID 3, with no ID 2.
My question is, assuming your results in Seattle if you have it don't contradict mine, is this quirk still present in more recent Delphi versions in particular Rio?
While you have the app running, there is another quirk which seems easily provoked:
Double-click the Name cell of the first row so that the StringGrid goes into editing mode.
Press the Down key.
When I do that, I get the CPU window up and
---------------------------
Debugger Exception Notification
---------------------------
Project BindingsQuirk2.exe raised exception class $C0000005 with message 'access violation at 0x095b9633: write of address 0x00000001'.
---------------------------
Break Continue Help
---------------------------
Code
type
TLBForm = class(TForm)
ADataSet: TSimpleDataSet;
ADataSetID: TIntegerField;
ADataSetName: TStringField;
BindSourceDB1: TBindSourceDB;
StringGrid1: TStringGrid;
BindingsList1: TBindingsList;
NavigatorBindSourceDB1: TBindNavigator;
LinkGridToDataSourceBindSourceDB1: TLinkGridToDataSource;
procedure FormCreate(Sender: TObject);
procedure ADataSetNewRecord(DataSet: TDataSet);
private
NextID : Integer;
ALinkGridToDataSourceBindSourceDB1: TLinkGridToDataSource;
end;
[...]
procedure TLBForm.ADataSetNewRecord(DataSet: TDataSet);
begin
Inc(NextID);
ADataSetID.AsInteger := NextID;
ADataSetName.AsString := 'RowID' + IntToStr(NextID);
end;
procedure TLBForm.FormCreate(Sender: TObject);
var
i : Integer;
begin
ADataSet.IndexFieldNames := 'ID';
ADataSet.OnNewRecord := ADataSetNewRecord;
ADataSet.CreateDataSet;
for i := 1 to 3 do begin
ADataSet.Insert;
ADataSet.Post;
end;
ADataSet.First;
end;
DFM extract
object LBForm: TLBForm
object StringGrid1: TStringGrid
CanFocus = True
ClipChildren = True
Position.X = 8.000000000000000000
Position.Y = 16.000000000000000000
TabOrder = 26
Viewport.Width = 180.000000000000000000
Viewport.Height = 75.000000000000000000
end
object NavigatorBindSourceDB1: TBindNavigator
Position.X = 8.000000000000000000
Position.Y = 128.000000000000000000
Size.Width = 240.000000000000000000
Size.Height = 25.000000000000000000
Size.PlatformDefault = False
TabOrder = 31
DataSource = BindSourceDB1
xRadius = 4.000000000000000000
yRadius = 4.000000000000000000
end
object ADataSet: TSimpleDataSet
Aggregates = <>
DataSet.MaxBlobSize = -1
DataSet.Params = <>
Params = <>
OnNewRecord = ADataSetNewRecord
object ADataSetID: TIntegerField
FieldName = 'ID'
end
object ADataSetName: TStringField
FieldName = 'Name'
Size = 30
end
end
object BindSourceDB1: TBindSourceDB
DataSet = ADataSet
ScopeMappings = <>
end
object BindingsList1: TBindingsList
Methods = <>
OutputConverters = <>
object LinkGridToDataSourceBindSourceDB1: TLinkGridToDataSource
DataSource = BindSourceDB1
GridControl = StringGrid1
Columns = <>
end
end
end
User contributions licensed under CC BY-SA 3.0