Print Page | Close Window

Using PrintDialog with CR

Printed From: Crystal Reports Book
Category: Crystal Reports .NET 2003
Forum Name: Writing Code
Forum Discription: .NET 2003 programming API, report integration
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=393
Printed Date: 06 May 2024 at 6:13pm


Topic: Using PrintDialog with CR
Posted By: pooba53
Subject: Using PrintDialog with CR
Date Posted: 23 Mar 2007 at 12:44pm
I would like to use the PrintDialog function with CR, but have not found any examples of how this is accomplished. Right now I simply print doing:

MyReport.PrintToPrinter(1, False, 0, 0)

My client wants the dialog box to pop up Embarrassed

Thanks!
-Dan



Replies:
Posted By: BrianBischof
Date Posted: 23 Mar 2007 at 12:51pm
I haven't done that before. I think you have to open it yourself (it is part of the .NET library). Either that or preview it to the user and then when they print it will pop up.

-------------
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>


Posted By: pooba53
Date Posted: 23 Mar 2007 at 12:54pm
I'm wading through the documentation on the PrinterDialog class trying to figure out how to accomplish this. A lovely way to spend a Friday afternoon. Amazing how many Google's of folks wondering how to accomplish this.

I shall dive in and report back my findings, Captain.


Posted By: BrianBischof
Date Posted: 23 Mar 2007 at 1:13pm
Thanks. I'll have to make sure I research this one for the .NET 2005 book. It's a good topic.

The problem with .NET 2003 is that not all properties of the Printer Dialog box can be passed to the ReportDocument class. So it will be good to hear what learn. (I'm spending my Friday researching custom role membership providers to integrate with an ASP.NET menu system - then tonight it's all night on the XI book). Fun fun fun...

-------------
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>


Posted By: pooba53
Date Posted: 23 Mar 2007 at 1:37pm
So the 8 parameters associated with ReportDocument.PrintOptions are all I have to work with and how those values are set must be captured from the PrintDialog class, correct?

Eesh...you are having more fun than I on this fine Friday.


Posted By: BrianBischof
Date Posted: 23 Mar 2007 at 2:39pm
Yep. That's what you gotta do.

-------------
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>


Posted By: pooba53
Date Posted: 27 Mar 2007 at 2:17pm
Ended up creating my own "PrintDialog" function by populating a combo box like so:

Dim i As Integer
        Dim pkInstalledPrinters As String

        For i = 0 To PrinterSettings.InstalledPrinters.Count - 1
            pkInstalledPrinters = PrinterSettings.InstalledPrinters.Item(i)
            ComboBox1.Items.Add(pkInstalledPrinters)
        Next

Then I simply captured the number of copies and name of printer and used them with the PrintToPrinter thingy. 


Posted By: BrianBischof
Date Posted: 27 Mar 2007 at 3:14pm
Interesting. Glad it works.

-------------
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>


Posted By: pooba53
Date Posted: 27 Mar 2007 at 6:22pm
Yeah, I could not find a way to make PrintDialog work directly with the ReportDocument class as you mentioned above.

-Dan


Posted By: harisphang
Date Posted: 05 Apr 2007 at 7:41am
well, what you need to do is very simple:
 

ReportDocument rd = new ReportDocument();

rd.Load(@"c:\test\test.rpt");

CrystalReportViewer crv = new CrystalReportViewer();

crv.ReportSource = rd;

crv.PrintReport();



Posted By: pooba53
Date Posted: 05 Apr 2007 at 7:46am
That brings up a print dialog?


Posted By: BrianBischof
Date Posted: 05 Apr 2007 at 11:14am
No, that is just code to load the report. To bring up the print dialog look in the help file for Visual Studio. I think they have sample code on how to load the Print Dialog for your application.

-------------
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>


Posted By: harisphang
Date Posted: 05 Apr 2007 at 7:18pm
Yes, it will. have you tried it?


Posted By: BrianBischof
Date Posted: 06 Apr 2007 at 1:04am
Ahhh. I see.  I didn't notice the PrintReport() method call. My mistake.

-------------
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>



Print Page | Close Window