From 3317b03e1d775d4e40c70fc4cfb379e794e76e7a Mon Sep 17 00:00:00 2001 From: alexs75 Date: Tue, 30 Oct 2018 13:49:40 +0000 Subject: [PATCH] RxFPC:TRxMemoryData.CopyStructure also copies the format of the field git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6700 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/rx/trunk/rxdb/rxmemds.pas | 29 ++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/components/rx/trunk/rxdb/rxmemds.pas b/components/rx/trunk/rxdb/rxmemds.pas index b453f6bad..97f356273 100644 --- a/components/rx/trunk/rxdb/rxmemds.pas +++ b/components/rx/trunk/rxdb/rxmemds.pas @@ -96,6 +96,7 @@ type procedure ClearRecords; procedure InitBufferPointers(GetProps: Boolean); procedure ParseFilter(const AFilter: string); + procedure CopyFieldsFormat(ASource:TDataSet); protected procedure AssignMemoryRecord(Rec: TMemoryRecord; Buffer: PChar); function GetActiveRecBuf(var RecBuf: PChar): Boolean; virtual; @@ -667,6 +668,33 @@ begin end; end; +procedure TRxMemoryData.CopyFieldsFormat(ASource: TDataSet); +var + i: Integer; + F, F1: TField; +begin + if not Assigned(ASource) then Exit; + for i:=0 to Fields.Count-1 do + begin + F:=Fields[i]; + F1:=ASource.FindField(F.FieldName); + if Assigned(F1) then + begin + F.EditMask:=F1.EditMask; + if (F is TNumericField) and (F1 is TNumericField) then + begin + TNumericField(F).DisplayFormat:=TNumericField(F1).DisplayFormat; + TNumericField(F).EditFormat:=TNumericField(F1).EditFormat; + end + else + if (F is TDateTimeField) and (F1 is TDateTimeField) then + begin + TDateTimeField(F1).DisplayFormat:=TDateTimeField(F1).DisplayFormat; + end; + end; + end; +end; + procedure TRxMemoryData.ClearRecords; begin while FRecords.Count > 0 do TObject(FRecords.Last).Free; @@ -1539,6 +1567,7 @@ begin CheckDataTypes(FieldDefs); CreateFields; + CopyFieldsFormat(Source); end; (* procedure AssignRecord(Source, Dest: TDataSet; ByName: Boolean);