2016-10-05 2 views
0

I Создать компонент в Report Builder для создания массива меток в отчетах, та часть кода ниже:Delphi Report Builder Создание выполнения компонента Не показывать новый ярлык на экране

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; 

Этот код работает, но есть проблема: Когда я впервые показываю отчет на экране, новый ярлык, созданный этим кодом, не отображается, но если я закрываю и открываю экран предварительного просмотра, новые созданные ppLabels отображаются нормально. Я называю этот код событием BeforePrint на ppReport Есть ли какая-то команда Force ppReport обновить эту ppLabel или заставить перезагрузить весь отчет с помощью новых ярлыков?

ответ

1

Хм, я создал небольшой образец (см. Ниже), и он работает для меня. Не могли бы вы создать аналогичный образец, чтобы показать проблему?

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. 

и DFM файл

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 
0

Я думаю, что проблема является локальной, где был вставлен код для создания этикеток. Мое предложение состоит в том, чтобы поместить этот код в событие ppReport1InitializeParameters.

 Смежные вопросы

  • Нет связанных вопросов^_^