Solved

Print preview

Posted on 2012-03-13
2
443 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

626 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