Solved

Print preview

Posted on 2012-03-13
2
437 Views
Last Modified: 2012-03-14
Hi,

How can I change the code below to display the print preview before printing the form?

PrintDocument pd = new PrintDocument();
            pd.PrintPage += new PrintPageEventHandler(PrintImage);
            pd.Print();

Thanks

ayha
0
Comment
Question by:ayha1999
2 Comments
 
LVL 16

Accepted Solution

by:
Rose Babu earned 200 total points
ID: 37714908
Hi,

drag PrintPreviewDialog control to your form and and update your code as below.

Private Sub btnPrintPreview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrintPreview.Click

	PrintDocument pd = new PrintDocument();
	pd.PrintPage += new PrintPageEventHandler(PrintImage);

	PrintPreviewDialog1.Document .Document = pd
	PrintPreviewDialog1.Document .WindowState = FormWindowState.Maximized
	PrintPreviewDialog1.Document .ShowDialog()

End Sub

Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint.Click

	PrintDocument pd = new PrintDocument();
	pd.PrintPage += new PrintPageEventHandler(PrintImage);

	pd.Print();
	
End Sub

Open in new window


Try it. This may work for you.

for your reference

http://msdn.microsoft.com/en-us/library/274tyhz7.aspx

http://vb-helper.com/howto_net_print_and_preview.html

http://mindstick.com/Articles/f8fd0f1d-d6a1-4581-bf24-f72deaeda85b/?PrintDocument%20PrintPreviewDi
0
 
LVL 7

Author Closing Comment

by:ayha1999
ID: 37719514
Thanks
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question