Solved

Print preview

Posted on 2012-03-13
2
435 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

813 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now