473,769 Members | 2,331 Online
Bytes | Software Development & Data Engineering Community
+ 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 1482
You could try setting it to nothing:

MyPrintPreview. Document = Nothing

Robin S.
----------------------------------------
"Stuart Nathan" <st***********@ homecall.co.ukw rote in message
news:uc******** ******@TK2MSFTN GP03.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.Documen t = Nothing
PrintDoc = New Drawing.Printin g.PrintDocument
Preview.Documen t = 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.Documen t = ProductPrintDoc ument
Preview.ShowDia log()

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

Is that how you're doing it?

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

"Stuart Nathan" <st***********@ homecall.co.ukw rote in message
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
>I have.

The Code is

Preview.Documen t = Nothing
PrintDoc = New Drawing.Printin g.PrintDocument
Preview.Documen t = PrintDoc
Preview.Show

Dec 4 '06 #4
No.

I created it using
Dim WithEvents Preview as PrintPreviewCon trol

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.Do cument

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 PrintPreviewCon trol already has events, and
you should be able to capture them inherently.
On your form, click on the PrintPreviewCon trol
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(ByV al sender As System.Object, _
ByVal e As System.EventArg s) Handles PrintToolStripB utton.Click,
PrintToolStripM enuItem.Click
'This calls PrintPage for each page in ProductPrintDoc ument
'so that means it ends up calling ProductPrintDoc ument_PrintPage
' because that handles the ProductPrintDoc ument.PrintPage event.
' page in ProductPrintDoc ument.
ProductPrintDoc ument.Print()
End Sub

Private Sub PrintPreviewBut ton(ByVal sender As System.Object, _
ByVal e As System.EventArg s) _
Handles PrintPreviewToo lStripButton.Cl ick, _
PrintPreviewToo lStripMenuItem. Click
ProductPrintPre view.Document = ProductPrintDoc ument
'this shows the document in PrintPreview mode
'the user can print it from there or cancel
ProductPrintPre view.ShowDialog ()
End Sub

Private Sub ProductPrintDoc ument_PrintPage (ByVal sender As Object, _
ByVal e As System.Drawing. Printing.PrintP ageEventArgs) _
Handles ProductPrintDoc ument.PrintPage
Try
ProcessPrintPag e(sender, e)
Catch ex As InvalidOperatio nException
MessageBox.Show (My.Resources.P rintErrActiveFo rm)
End Try
End Sub

Robin S.
------------------------------------------
"Stuart Nathan" <st***********@ homecall.co.ukw rote in message
news:%2******** *******@TK2MSFT NGP02.phx.gbl.. .
No.

I created it using
Dim WithEvents Preview as PrintPreviewCon trol

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.Do cument

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

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

Similar topics

1
2024
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 "wingdings".
0
1005
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 ( text file in this case) that has more than 12 pages ( I tried with a 50 page document too), instead of being able to see all 12+ pages in the Preview Window, all you see are Blank Pages!! But, preview a document with less than that, it will show...
6
1221
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
2110
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 so I am using PrintPreviewDialog. It prints fine. But the PrintPreview dialog shows only one blank page. Before I resort to posting code, is there some simple and/or common mistake I could have made which would explain why PrintPreview shows...
0
9589
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10222
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10050
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9999
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9866
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6675
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5310
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2815
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.