Uniquery1.Assign command

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
smelchi
Posts: 15
Joined: Fri 18 Jun 2010 16:37

Uniquery1.Assign command

Post by smelchi » Tue 03 Mar 2015 14:41

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.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Uniquery1.Assign command

Post by AlexP » Tue 03 Mar 2015 15:11

Hello,

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;

smelchi
Posts: 15
Joined: Fri 18 Jun 2010 16:37

Re: Uniquery1.Assign command

Post by smelchi » Fri 03 Apr 2015 20:06

Uniquery1.Assign( dataModule.Uniquery1) copy fielddefs without DisplayLabel.

How can I copy Displaylabel too?

Copying events is OK. Thanks for your answer.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Uniquery1.Assign command

Post by AlexP » Mon 06 Apr 2015 07:59

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;

Post Reply