Ron,
I think I was confusing the feature you get in Word and Excel where you can
select a range like "1,3,7,10" or "1 to 5, 9", in fact that "selection"
option doesn't offer anything when you click the option button in the
dialog, I thought when you enabled this it would offer you a text box to
enter your selection of pages. I suspect you can do it but I haven't found
how yet.
Once I had got that far, I hit another snag in that I don't think there is
any easy way whilst printing is going on for you to know which of the
selection has caused the print handler routine to trigger. I guess MS must
use the selection to preprocess the whole print job before calling the print
routine, so the print routine is always passed a contiguous set of pages
even though they might actually be pages 1,3,5 and 9 or whatever from the
possible set of pages.
When you are in the print handler you are just dealing with what has been
sent, you shouldn't be trying to alter the order of things within that
appears to be the way it should be approached.
If you are dealing with a from and to range, that is easier to be handled
within the print routine itself as you can get the from and to values as you
say and then it is easy to work out what should be printed from that. If
anyone else knows a better way to do a selection I would be interested, I
suppose you could write a custome print dialog rather than using the
standard one.
Thanks for your response.
Siv
"Ron Allen" <Ro******@newsgroups.nospam> wrote in message
news:Ov**************@TK2MSFTNGP10.phx.gbl...
Siv,
If I look at the PrinterSettings I get back from a PrintDialog when I
set AllowSomePages I get a FromPage and a ToPage property set with the
values I enter. If you pass this PrinterSettings to your PrintDocument
you should have the pages you want using your case statement. I don't
normally use this for anything as my users are mostly printing the reports
for archival purposes and want the whole document.
I always pass the PrinterSettings from the PrintDialog to the
PrintDocument to avoid having to set a lot of properties.
Ron Allen
"Siv" <dotnet@remove_me.sivill.com> wrote in message
news:OG**************@TK2MSFTNGP10.phx.gbl... Hi,
I'll try that again with a bit more attention paid to what I typed:
It should have read:
I am getting into printing with VB.NET 2005 and want to implement the
usual
capability that a user can select a selection of pages. I have a report
that is generated by my application that if the user wants all pages will
produce 3 pages. I want to offer the user the ability to select via the
print dialog that only pages 1 and 2 of it are printed or possibly pages
1
and 3 but not 2.
At the moment I can produce all three pages either as a print without a
preview, or via a print preview.
I have printing routine that handles the PrintPage event of the document
object used for this report.
My issue is how do I work out when the print handler routine is called
which
of the pages is being printed at the time, ideally I want to have a
select
case statement in my printing routine that says:
Select Case MyDoc.PrinterSettings.PrintRange.PageNumber
'I know PageNumber doesn't exist, but there must be a way of getting
it??
Case 1
'Printing commands for page 1
Case 2
'Printing commands for page 2
Case 2
'Printing commands for page 3
End Select
I feel like I am missing something and am probably making this more
complicated than it is?
Any help, or links to web sources that describe the process would be
appreciated. I have 3 books on programming in VB.NET and none of them
cover
the subject of how you deal with printing a selection of pages. I also
cannot find anything by googling that deals with this issue.
Siv