Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Printing using a data reader

0 views
Skip to first unread message

Kyle Dunn

unread,
Jan 28, 2002, 9:45:13 AM1/28/02
to
In a PrintPage event I am opening a data reader and reading the records
in a while loop. When I reach the MarginBounds I am setting
e.HasMorePages to true followed by a return statement. When the next
page attempts to print and the PrintPage event executes again it runs
all of the code within the PrintPage method creating an error condition
and does not just continue at the same place in the while loop. How is
the process of printing a large number of records from a database
usually handled?

Kyle

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nicholas Paldino [.NET MVP]

unread,
Jan 28, 2002, 11:14:50 AM1/28/02
to
Kyle,

When the PrintPage event fires, you should be monitoring on your own
what page you are printing. It appears that you are not maintaining the
state correctly between pages. This event fires for the printing of a
single page.

Also, why are you fetching data in this event? I am somewhat perplexed
by this. I would think that you want to print the contents of a document
that has already been generated.

Hope this helps.

--
- Nicholas Paldino [.NET MVP]
- nicholas...@exisconsulting.com

"Kyle Dunn" <ky...@trustline.com> wrote in message
news:uiWrlpAqBHA.2056@tkmsftngp03...

Kyle Dunn

unread,
Jan 28, 2002, 11:53:21 AM1/28/02
to
My problem is inexperience. This is the first time I have ever printed
in an object oriented environment and I don't have a clue as to the
proper approach.

At the moment I'm using the graphics object that is passed to the
PrintPage event through

System.Drawing.Printing.PrintPageEventArgs e

and setting ojects to print like

Image LogoImage;
LogoImage = new Bitmap("Logo.jpg");
e.Graphics.DrawImage(LogoImage, x, y);

or using the DrawString or FillRectangle methods to generate the output.
This does work as long as it is only one page. I see I need to be
generating the page outside the the PrintPage event but does this mean
when you say to print the contents of a document that has already been
generated, you mean generated in memory or in a file? Can you give me
an example?

It makes sense that I am not maintaining state correctly between the
pages. Can you give me an example or a lead to an article that
demonstrates this?

I do greatly appreciate your reply and wish I had a better handle on
what do to. Thank you for your response and any additional help would
be appreciated.

Nicholas Paldino [.NET MVP]

unread,
Jan 28, 2002, 12:20:14 PM1/28/02
to
Kyle,

Think of your printing as one big puzzle, with the pages being the
pieces of that puzzle. As you print out page after page, you should keep
track of what you have printed, and where you are printing it. The thing
with this puzzle is that the pieces form one long strip.

In that sense, you should keep track of the position in the data set
that you are at when you print, printing what you want on each page. When
the event fires again, pick up from where you left off and continue.

--
- Nicholas Paldino [.NET MVP]
- nicholas...@exisconsulting.com


"Kyle Dunn" <ky...@trustline.com> wrote in message

news:#aJHMxBqBHA.1964@tkmsftngp07...

0 new messages