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
This commit is contained in:
alexs75
2018-10-30 13:49:40 +00:00
parent cb740638d9
commit 3317b03e1d

View File

@ -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);