Question
“How do I start printing on the label of my choice when printing to a label sheet such as Avery?”
Solution
Use the DetailBand.BeforePrint event to keep track of the label that is being printed. Then toggle the visibility of the components in the detail band based on which labels you would like to print.
This can be helpful for instances where you are printing to a label template page with individual labels missing or that have already been used.
Download: SkipLabels.zip
Sample Delphi code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
procedure TForm1.InitializeReport; begin ppReport1.DetailBand.BandsPerRecord := FSkip + FLabelsPerRecord; FTotalBandsPerColumn := 0; ppDBCalc1.Visible := False; ppDBText1.Visible := False; end; procedure TForm1.ppReport1StartPage(Sender: TObject); begin if (ppReport1.AbsolutePageNo = 1) then InitializeReport; end; procedure TForm1.ppDetailBand1BeforePrint(Sender: TObject); var liBandsGenerated: Integer; begin liBandsGenerated := ((ppReport1.CurrentColumn - 1) * FTotalBandsPerColumn) + ppReport1.DetailBand.Count; if (liBandsGenerated = FSkip) then begin ppDBCalc1.Visible := True; ppDBText1.Visible := True; end else if (liBandsGenerated = FSkip+FLabelsPerRecord) and (ppReport1.DataPipeline.RecordNo = 1) then ppReport1.DetailBand.BandsPerRecord := FLabelsPerRecord; end; procedure TForm1.ppReport1EndColumn(Sender: TObject); begin if (FTotalBandsPerColumn = 0) then FTotalBandsPerColumn := ppReport1.DetailBand.Count; end; |