Home Component Writing
New Blog Posts: Merging Reports - Part 1 and Part 2

creating pplabel in region on runtime

edited January 2011 in Component Writing
Hey,

i have little problem by creating an array of pplabel on a region. The Code
seems to work, but i can't see the labels

Setlength(ppLBankLabel,ibds.FieldList.Count);
for i := 0 to ibds.FieldList.Count-1 do
begin
if not Varisnull(ibds.Fields[i].Value) then
begin
ppLBankLabel[i] := TppLabel.Create(ppReport1);
ppLBankLabel[i].Band := ppSummaryBand1;
ppLBankLabel[i].Region := ppRBank;
ppLBankLabel[i].Left := CompleteWidth;
ppLBankLabel[i].Top := pprbank.Top + 0.2;
ppLBankLabel[i].Caption := ibds.Fields[i].AsString;
CompleteWidth := CompleteWidth + ppLBankLabel[i].Width + 1;
ppLBankLabel[i].BringToFront;
end;
end;

I tried lots of different events for executing this code. know it's in
ppSummaryBand1AfterPrint
Does anyone know what the failure is?

Comments

  • edited January 2011
    Hi Jannes,

    If you are adding components to the summary band, you will want to use an
    event that fires before it is printed. I suggest using the
    SummaryBand.BeforePrint. Also be sure to remember that once you assign a
    Region, you are in the confines of that region when setting the position of
    the label. I suggest testing with some hard coded numbers and a single
    label to get something to show up then tracing your Left/Top values with
    your existing code to be sure everything is in the visible area.



    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited January 2011
    Hi Nico,

    thanks for your fast response. I made now this simple example

    procedure TzRepReceipt.ppSummaryBand1AfterPrint(Sender: TObject);
    var
    testlabel : TppLabel;
    begin
    inherited;
    testlabel := TppLabel.Create(ppSummaryBand1);
    testlabel.Band := ppSummaryBand1;
    testlabel.Left := 5;
    TestLabel.Top :=5;
    testlabel.Caption :='Test';
    testlabel.Width := 50;
    testlabel.Visible :=True;
    testlabel.BringToFront;
    testlabel.Transparent := True;
    testlabel.UserName := 'Bla';
    end;

    when i put this code in other bands, it works. but not on ppSummaryBand1. i
    already made all other components on this band invisible, in case it's
    behind something. but it's not there. Do you have any idea?
    Regards
    Jannes


This discussion has been closed.