Trying to set report viewer template at runtime.
?I am certain this is alot easier than what it seems. I am trying to
allow the user to double click a report filename from a list box and
send that report to the report viewer.
I set the template filename with the selected filename and call the
LoadFromFile method. But nothing ever happens in the viewer.
I have tried the reset method on the viewer and setting the viewer
template property again. Nothing seems to work.
I have looked at the Report Example application and it seems that each
Report is attached to its own form which is assigned to the viewer.
Surely it must be easier than this.
Thanks for helping out a newbie.
caplen
--- posted by geoForum on http://delphi.newswhat.com
allow the user to double click a report filename from a list box and
send that report to the report viewer.
I set the template filename with the selected filename and call the
LoadFromFile method. But nothing ever happens in the viewer.
I have tried the reset method on the viewer and setting the viewer
template property again. Nothing seems to work.
I have looked at the Report Example application and it seems that each
Report is attached to its own form which is assigned to the viewer.
Surely it must be easier than this.
Thanks for helping out a newbie.
caplen
--- posted by geoForum on http://delphi.newswhat.com
This discussion has been closed.
Comments
There is a tutorial in the ReportBuilder Developers Guide that show how to
do this. Basically you need to load the template and call the print method.
myReport.Template.FileName := 'c\myReports\Invoice.rtm';
myReport.Template.LoadFromFile;
myReport.Print;
--
Nard Moseley
Digital Metaphors
www.digital-metaphors.com
Best regards,
Nard Moseley
Digital Metaphors
www.digital-metaphors.com
Thank you for your reply. I have not had a chance to try this for a few
days. This works, but with one issue. We have created a form that has a
listbox of templates on the left and a report viewer on the right. What we
want is to have the user double click a report on the left and set the
report to be viewed on the right. When the code below is run, a report
viewer pops up with the report. When I run the following code, the report
viewer in our form correctly displays the report, but we still get the
second pop up viewer.
ppReport.Template.FileName := IncludeTrailingBackslash(szFSPath) +
lboxTemplates.Items[lboxTemplates.ItemIndex] + templateExt;
ppReport.Template.LoadFromFile;
ppViewer.Report := ppReport;
ppViewer.Report.Print;
How can I work around this?
Thank you
You need to call the PrintToDevices method rather than the Print method.
Please the ReportBuilder help topics for these methods. See the
RBuilder\Demos\Reports for an example of the type of app you are describing.
I recommend spending some time with the Developers Guide, Demos, and Help
etc.
--
Nard Moseley
Digital Metaphors
www.digital-metaphors.com
Best regards,
Nard Moseley
Digital Metaphors
www.digital-metaphors.com