By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,512 Members | 3,689 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,512 IT Pros & Developers. It's quick & easy.

Help Needed WIth Printing BN.NET 2005

P: n/a
Siv
Hi,
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
Case 1
'Printing command for page 1
Case 2
'Printing command for page 1
Case 2
'Printing command for page 1
End Select

I feel like I am missing something and am probably making this mor
ecomplicated 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
Mar 31 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Siv
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
Mar 31 '06 #2

P: n/a

"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

Look in Help under the PrintDocument's PrinterSettings:

PrintDocument.PrinterSettings.PrintRange = According to Intelisense,
gets or sets the number of pages the user wants to print.

james


Mar 31 '06 #3

P: n/a
Siv
James,

I did, and I can't get the range into an array, no matter what I try it
gives me syntax errors about the assignment from the PrintSettings to my
array.

Also even if I could get the array, I am struggling to understand how I can
find out what page I am currently processing, there is no "this handler is
being called by the printing of page 2" type properties that I can find?

I can maintain my own static variable so I know how many times the routine
has been entered, but if we are printing say a 5 page document (if the user
were to print all the pages), but actually decides to go for 1,3,5 that
method doesn't cut it because when the 2nd page is being printed, it is
actually page 3 that should be produced.

I am beginning to think I have got this printing thing "arse about face",
perhaps I should preprocess the page data in code and thus ensure that what
is sent to the printer is always a contiguous stream of pages even though in
reality that is 1,3,5 of the total report.

I don't want to use Crystal as I have used it in the past and always spent
days designing a report that isn't quite how I want it to be and I always
seem to hit a brick wall with it and end up throwing away what I have done.
Also I would really like to get to the bottom of printing directly within
the .NET framework as I feel I am nearly there but just a few annoying
niggles.

Siv

"james" <jj***************@earthlink.net> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...

"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

Look in Help under the PrintDocument's PrinterSettings:

PrintDocument.PrinterSettings.PrintRange = According to Intelisense,
gets or sets the number of pages the user wants to print.

james


Mar 31 '06 #4

P: n/a
Siv, sorry I didn't read your post better than I did. Or I would have
noticed that you did try the PrintRange settings.
I too have been working with printing in VB2005 ( and 2003) and have found
passing the PrintDialog Settings to be
a bit problematic. At times, it seems I can almost make it work and then I
hit an error. What is confusing to me is
the Inteli-Sense says that some of those properties both GET & SET values.
But, when I try to set values using values
from the PageSetupDialog, I run into errors like you do. I will let you know
if I have any more luck with it.
I a currently trying something different.
james
"Siv" <dotnet@remove_me.sivill.com> wrote in message
news:uU**************@TK2MSFTNGP12.phx.gbl...
James,

I did, and I can't get the range into an array, no matter what I try it
gives me syntax errors about the assignment from the PrintSettings to my
array.

Also even if I could get the array, I am struggling to understand how I
can find out what page I am currently processing, there is no "this
handler is being called by the printing of page 2" type properties that I
can find?

I can maintain my own static variable so I know how many times the routine
has been entered, but if we are printing say a 5 page document (if the
user were to print all the pages), but actually decides to go for 1,3,5
that method doesn't cut it because when the 2nd page is being printed, it
is actually page 3 that should be produced.

I am beginning to think I have got this printing thing "arse about face",
perhaps I should preprocess the page data in code and thus ensure that
what is sent to the printer is always a contiguous stream of pages even
though in reality that is 1,3,5 of the total report.

I don't want to use Crystal as I have used it in the past and always spent
days designing a report that isn't quite how I want it to be and I always
seem to hit a brick wall with it and end up throwing away what I have
done. Also I would really like to get to the bottom of printing directly
within the .NET framework as I feel I am nearly there but just a few
annoying niggles.

Siv

"james" <jj***************@earthlink.net> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...

"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

Look in Help under the PrintDocument's PrinterSettings:

PrintDocument.PrinterSettings.PrintRange = According to Intelisense,
gets or sets the number of pages the user wants to print.

james



Mar 31 '06 #5

P: n/a
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

Apr 1 '06 #6

P: n/a
Siv
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


Apr 2 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.