Hi,
Uniquery1.Assign( dmDataModule.Uniquery1) command didn´t copy events from source.
Uniquery1:= dmDataModule.Uniquer1 copy events.
I would like to copy dmDataModule.Uniquery1 on my form without to link directly do dmDataModule.Uniquery1.
Is there another solution?
Thanks.
Uniquery1.Assign command
Re: Uniquery1.Assign command
Hello,
If you want to use the same event in different datasets, it is enough to set the event after calling the Assign method:
If you want to use the same event in different datasets, it is enough to set the event after calling the Assign method:
Code: Select all
UniQuery2.Assign(UniQuery1);
UniQuery2.AfterOpen := UniQuery1.AfterOpen;
Re: Uniquery1.Assign command
Uniquery1.Assign( dataModule.Uniquery1) copy fielddefs without DisplayLabel.
How can I copy Displaylabel too?
Copying events is OK. Thanks for your answer.
How can I copy Displaylabel too?
Copying events is OK. Thanks for your answer.
Re: Uniquery1.Assign command
The DisplayLabel property is a property of the TField class, not of FieldDefs. When calling the Assign method, we don't copy Field and FieldDef, they are created on opening the DataSet. You can set the DisplayLabel property for each field in a loop.
Code: Select all
UniQuery2.Assign(UniQuery1);
ShowMessage(IntToStr(UniQuery2.Fields.Count)); //<--0
ShowMessage(IntToStr(UniQuery2.FieldDefs.Count)); //<--0
UniQuery2.OPen;
for i := 0 to UniQuery1.FieldCount - 1 do begin
UniQuery2.Fields[i].DisplayLabel := UniQuery1.Fields[i].DisplayLabel;
end;