Reputation: 157
I Create a component in Report Builder to Create a array of Labels on Reports, the part of code is bellow:
for I := 0 to 20 do begin
Txt := TppLabel.Create(Report);
Txt.Caption := GradePipeLine.GetFieldAsString('Grade') ;
Txt.Left := StartLeft;
Txt.Top := StartTop;
Txt.Band := Band;
Txt.AutoSize := AutoSize;
Txt.Width := TmpWidth;
Txt.Font := Font;
Txt.TextAlignment := TextAlignment;
Txt.Border := Border;
Txt.Transparent := true;
Txt.Tag := -50000;
StartLeft := TmpEspacamento + StartLeft;
end;
This Code works, but have a problem, When I Show the report on screen at first time the new label created by this code are not show, but if I close and open the preview screen the new ppLabels created are showed normal. I call this code on BeforePrint Event on ppReport There is some comand to Force ppReport update this ppLabel or force reload all report with this new labels ?
Upvotes: 0
Views: 3082
Reputation: 1
I think the problem is the local where the code to create the labels was inserted. My suggestion is to put this code in the ppReport1InitializeParameters
event.
Upvotes: 0
Reputation: 483
Hm, I've created a small sample (see below) and it works for me. Could you please create a similar sample to show the problem?
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, ppBands, ppCache, ppClass,
ppDesignLayer, ppParameter, ppComm, ppRelatv, ppProd, ppReport, Vcl.StdCtrls,
ppEndUsr, ppPrnabl, ppCtrls;
type
TForm1 = class(TForm)
ppReport1: TppReport;
ppParameterList1: TppParameterList;
ppDesignLayers1: TppDesignLayers;
ppDesignLayer1: TppDesignLayer;
ppHeaderBand1: TppHeaderBand;
ppDetailBand1: TppDetailBand;
ppFooterBand1: TppFooterBand;
Button1: TButton;
ppDesigner1: TppDesigner;
procedure Button1Click(Sender: TObject);
procedure ppReport1BeforePrint(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses
ppIniStorage;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
LDesigner: TppDesigner;
begin
LDesigner := TppDesigner.Create(nil);
try
LDesigner.Caption := 'Invoice Report Designer';
LDesigner.IniStorageType := TppIniNone.ClassDescription;
LDesigner.Report := ppReport1;
LDesigner.ShowModal;
finally
LDesigner.Free;
end;
end;
procedure TForm1.ppReport1BeforePrint(Sender: TObject);
const
TmpEspacamento = 0.7;
StartTop = 0.1875;
AutoSize = True;
TmpWidth = 0.5;
var
I: Integer;
Txt: TppLabel;
StartLeft: Double;
begin
StartLeft := 0.083300002;
for I := 0 to 2 do
begin
Txt := TppLabel.Create(ppReport1);
Txt.Caption := Format('Label %d', [I]);//GradePipeLine.GetFieldAsString('Grade') ;
Txt.Left := StartLeft;
Txt.Top := StartTop;
Txt.Band := ppHeaderBand1;
Txt.AutoSize := AutoSize;
Txt.Width := TmpWidth;
Txt.Font := Font;
//Txt.TextAlignment := TextAlignment;
//Txt.Border := Border;
Txt.Transparent := true;
Txt.Tag := -50000;
StartLeft := TmpEspacamento + StartLeft;
end;
end;
end.
and DFM file
object Form1: TForm1
Left = 0
Top = 0
Caption = 'Form1'
ClientHeight = 290
ClientWidth = 554
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Button1: TButton
Left = 12
Top = 8
Width = 75
Height = 25
Caption = 'Button1'
TabOrder = 0
OnClick = Button1Click
end
object ppReport1: TppReport
PrinterSetup.BinName = 'Default'
PrinterSetup.DocumentName = 'Report'
PrinterSetup.PaperName = 'Letter'
PrinterSetup.PrinterName = 'Default'
PrinterSetup.SaveDeviceSettings = False
PrinterSetup.mmMarginBottom = 6350
PrinterSetup.mmMarginLeft = 6350
PrinterSetup.mmMarginRight = 6350
PrinterSetup.mmMarginTop = 6350
PrinterSetup.mmPaperHeight = 279400
PrinterSetup.mmPaperWidth = 215900
PrinterSetup.PaperSize = 1
ArchiveFileName = '($MyDocuments)\ReportArchive.raf'
BeforePrint = ppReport1BeforePrint
DeviceType = 'Screen'
DefaultFileDeviceType = 'PDF'
EmailSettings.ReportFormat = 'PDF'
LanguageID = 'Default'
OutlineSettings.CreateNode = True
OutlineSettings.CreatePageNodes = True
OutlineSettings.Enabled = True
OutlineSettings.Visible = True
PDFSettings.EmbedFontOptions = [efUseSubset]
PDFSettings.EncryptSettings.AllowCopy = True
PDFSettings.EncryptSettings.AllowInteract = True
PDFSettings.EncryptSettings.AllowModify = True
PDFSettings.EncryptSettings.AllowPrint = True
PDFSettings.EncryptSettings.Enabled = False
PDFSettings.FontEncoding = feAnsi
PDFSettings.ImageCompressionLevel = 25
RTFSettings.DefaultFont.Charset = DEFAULT_CHARSET
RTFSettings.DefaultFont.Color = clWindowText
RTFSettings.DefaultFont.Height = -13
RTFSettings.DefaultFont.Name = 'Arial'
RTFSettings.DefaultFont.Style = []
TextFileName = '($MyDocuments)\Report.pdf'
TextSearchSettings.DefaultString = '<FindText>'
TextSearchSettings.Enabled = True
XLSSettings.AppName = 'ReportBuilder'
XLSSettings.Author = 'ReportBuilder'
XLSSettings.Subject = 'Report'
XLSSettings.Title = 'Report'
Left = 148
Top = 72
Version = '14.08'
mmColumnWidth = 0
object ppHeaderBand1: TppHeaderBand
Background.Brush.Style = bsClear
mmBottomOffset = 0
mmHeight = 13229
mmPrintPosition = 0
end
object ppDetailBand1: TppDetailBand
Background1.Brush.Style = bsClear
Background2.Brush.Style = bsClear
mmBottomOffset = 0
mmHeight = 13229
mmPrintPosition = 0
end
object ppFooterBand1: TppFooterBand
Background.Brush.Style = bsClear
mmBottomOffset = 0
mmHeight = 13229
mmPrintPosition = 0
end
object ppDesignLayers1: TppDesignLayers
object ppDesignLayer1: TppDesignLayer
UserName = 'Foreground'
LayerType = ltBanded
Index = 0
end
end
object ppParameterList1: TppParameterList
end
end
object ppDesigner1: TppDesigner
Caption = 'ReportBuilder'
DataSettings.SessionType = 'BDESession'
DataSettings.AllowEditSQL = False
DataSettings.GuidCollationType = gcString
DataSettings.IsCaseSensitive = True
DataSettings.SQLType = sqBDELocal
Position = poScreenCenter
IniStorageType = 'IniFile'
IniStorageName = '($LocalAppData)\RBuilder\RBuilder.ini'
WindowHeight = 400
WindowLeft = 100
WindowTop = 50
WindowWidth = 600
Left = 280
Top = 164
end
end
Upvotes: 1