473,473 Members | 4,189 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

PrintPreview Control

Can someone tell me how to remove a previously loaded PrintDocument in a
PrintPreview control, so that I can display a nedw one?
Dec 4 '06 #1
6 1458
You could try setting it to nothing:

MyPrintPreview.Document = Nothing

Robin S.
----------------------------------------
"Stuart Nathan" <st***********@homecall.co.ukwrote in message
news:uc**************@TK2MSFTNGP03.phx.gbl...
Can someone tell me how to remove a previously loaded PrintDocument in a
PrintPreview control, so that I can display a nedw one?

Dec 4 '06 #2
I have.

The Code is

Preview.Document = Nothing
PrintDoc = New Drawing.Printing.PrintDocument
Preview.Document = PrintDoc
Preview.Show

Dec 4 '06 #3
Okay, I'm no print expert, but I'll give this
a try.

This is how I'm doing it:

Preview.Document = ProductPrintDocument
Preview.ShowDialog()

Where ProductPrintDocument is my PrintDocument.
Then I have an event handler for
ProductPrintDocument.PrintPage that actually
outputs the information.

Is that how you're doing it?

Robin S.
------------------------------------------

"Stuart Nathan" <st***********@homecall.co.ukwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>I have.

The Code is

Preview.Document = Nothing
PrintDoc = New Drawing.Printing.PrintDocument
Preview.Document = PrintDoc
Preview.Show

Dec 4 '06 #4
No.

I created it using
Dim WithEvents Preview as PrintPreviewControl

I have tried a standard Dim statement and then adding an AddHandlern but no
difference there.

I do the "printing" in the PrintPage event, but this event is not raised
again even if I change the PrintPreview.Document

Dec 5 '06 #5
I'm on event expert, but here's what I think.
If you dim something WithEvents, you can raise
events and capture events on it. Are you doing
that?

The PrintPreviewControl already has events, and
you should be able to capture them inherently.
On your form, click on the PrintPreviewControl
and look at the properties. If you click on the
lightning bolt, it will show you the addressable
events. Although, I don't know why you would
need to do this.

Here is the code I'm using for my PrintPreview
and Print buttons. My PrintPage event is below also.
Will this work for you?

Private Sub PrintButton(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles PrintToolStripButton.Click,
PrintToolStripMenuItem.Click
'This calls PrintPage for each page in ProductPrintDocument
'so that means it ends up calling ProductPrintDocument_PrintPage
' because that handles the ProductPrintDocument.PrintPage event.
' page in ProductPrintDocument.
ProductPrintDocument.Print()
End Sub

Private Sub PrintPreviewButton(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles PrintPreviewToolStripButton.Click, _
PrintPreviewToolStripMenuItem.Click
ProductPrintPreview.Document = ProductPrintDocument
'this shows the document in PrintPreview mode
'the user can print it from there or cancel
ProductPrintPreview.ShowDialog()
End Sub

Private Sub ProductPrintDocument_PrintPage(ByVal sender As Object, _
ByVal e As System.Drawing.Printing.PrintPageEventArgs) _
Handles ProductPrintDocument.PrintPage
Try
ProcessPrintPage(sender, e)
Catch ex As InvalidOperationException
MessageBox.Show(My.Resources.PrintErrActiveForm)
End Try
End Sub

Robin S.
------------------------------------------
"Stuart Nathan" <st***********@homecall.co.ukwrote in message
news:%2***************@TK2MSFTNGP02.phx.gbl...
No.

I created it using
Dim WithEvents Preview as PrintPreviewControl

I have tried a standard Dim statement and then adding an AddHandlern but
no difference there.

I do the "printing" in the PrintPage event, but this event is not raised
again even if I change the PrintPreview.Document

Dec 5 '06 #6
The answer is the .InvalidatePreview method
Dec 6 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: LARB | last post by:
Good morning, I have a print routine where I use a "printpreview dialog' control. The text is perfect BUT when I then print the job all the text is completely crazy, a bit like...
0
by: james | last post by:
While trying to help another programmer on MSDN's Visual Basic 2005 Express Edition forum, he (and I ) ran into a strange problem with the PrintPreview Control in VB2005. If you load a document (...
6
by: Stuart Nathan | last post by:
Can someone tell me how to remove a previously loaded PrintDocument in a PrintPreview control, so that I can display a nedw one?
2
by: eBob.com | last post by:
I have a print application modeled on a program which I found via this newsgroup. (I still have comments in German in it!) The model uses ExtendedPrintPreviewDialog but I don't seem to have that...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.