Solved

Print preview

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Duplicate a row 2 29
Library to convert HTML to PDF. 8 44
Throws error on Decrypting String c# code 3 26
Data Saving(2) 2 21
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This video discusses moving either the default database or any database to a new volume.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

707 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

13 Experts available now in Live!

Get 1:1 Help Now