473,394 Members | 3,057 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Help Needed WIth Printing BN.NET 2005

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
6 4048
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

"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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: mscir | last post by:
+--------------------------------------------------------------------+ | Printing XML: Why CSS Is Better than XSL | | from the anything-you-can-do-i-can-do-better dept. ...
5
by: drdeadpan | last post by:
I asked the DBA to start the Server with options -T1204 and -T3605 and here's what I get. I need help deciphering this. This happens when we have 5 usrs performing concurrent actions and for the...
5
by: NG | last post by:
Hi, We are having DB2-V7.2 DB on AIX 5.2 machine. Recently we upgraded our system to fixpack 13 and activated activate AIX asynchronous IO function. Our DB is going to crash recovery with...
7
by: ChadDiesel | last post by:
Hello everyone, I'm having a problem with Access that I need some help with. The short version is, I want to print a list of parts and part quantities that belong to a certain part group---One...
1
by: Mika M | last post by:
Hi! I have some problems with setting PrintDocument margins using PageSetupDialog. Here some code to explain my problem... First PrintDocument declaring this way... Private pd As...
5
by: ComputerStop | last post by:
I am attempting to print a datagridview. I have not found any method that works successfully. Has any one been successful with this?
2
by: Teemu | last post by:
I have an application created with VB6 and now I'm converting it to VB 2005. Conversion is not so simple because printing is so much different. In my app I have Timer-component, which is creates...
0
by: Ricardo Bessa | last post by:
Hello, I'm using Reporting Services 2005 and i'm trying to print a report using RsClientPrint.Print(); When the report has no parameters there's no problem. But when the report have...
0
by: rafiki31 | last post by:
I have been hitting walls trying to find the right way to print from a web application. Here is the thing, im implementing a webapplication for a kiosk. The kiosk has its own card printer. When i...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
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...

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.