Printdocument.PrintPage cancel current printpage

G

Guest

Hi, can anyone tell me how to cancel the printing of the current page while
in the Printdocument.PrintPage event. I don't want to cancel the whole
printjob!
I need this for printing only the user defined selected pages or the from/to
pages.

Coen
 
G

Guest

The PrintPageEventArgs object's graphics object has a Clear. I believe that
just clears the current page. I've never tried this so you'll have to
experiment a bit. You might be able to just clear the page and return and
..Net will skip the page. More likely, though, you'll have to go on to your
next page routine without exitting that routine.

For your needs, though, I think it might be better to have a common routine
called for all pages. The routine would keep track of what pages have and
haven't printed and call the print routines for your pages.

Something like this....

Sub PagePrint(ByVal sender As Object, ByVal e As Printing.PrintPageEventArgs)
mnPage += 1 'higher level variable set to 0 at the start of job by
another routine
if UserWantsThisPage(mnPage) then
select case mnPage
case 1: PrintCoverPage
case 2,3,4: PrintOneOfThesePages
case 5: PrintLastPage
end select
end if
end sub
 
T

Tall Dude

Did you try e.HasMorePages = False ?

A lot of printpage event handlers use more than one logic point to set this.
You can then 'return' from a midpoint in the printpage handler.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top