Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Print preview

Posted on 2012-03-13
2
Medium Priority
?
461 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 800 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
Loops Section Overview
Screencast - Getting to Know the Pipeline

772 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