473,406 Members | 2,293 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,406 software developers and data experts.

printing two pages

hi

i'm not to good at this stuff yet... but I hope some can help me
My problem is that I want to print two pages from my program
I tried to set the HasMorePages = true but it keeps posting the same stuff on the two pages, or sometimes the second page over the first page

my code looks like this

int i = 0

while ( i < 2

switch ( i )

case 0
WHAT I WANT TO PRINT ON PAGE ON

case 1
WHAT I WANT TO PRINT ON PAGE TW

e.HasMorePage = i < 1
i++

Nov 16 '05 #1
4 4749
Hi,

Do you mean the code below is inside a printpage handler, if so, you
shouldn't use a while-construct. Store the i variable outside the
function. When you set hasmorepage = true then the event will be fired
again for the second page and so on... set it to false if you're at the last
page.

hth,
greetings
"Joakim Olsson" <jo***********@mail.com> wrote in message
news:D4**********************************@microsof t.com...
hi.

i'm not to good at this stuff yet... but I hope some can help me.
My problem is that I want to print two pages from my program.
I tried to set the HasMorePages = true but it keeps posting the same stuff on the two pages, or sometimes the second page over the first page.
my code looks like this:

int i = 0;

while ( i < 2 )
{
switch ( i )
{
case 0:
{

WHAT I WANT TO PRINT ON PAGE ONE

}

case 1:
{

WHAT I WANT TO PRINT ON PAGE TWO

}
}
e.HasMorePage = i < 1;
i++;

Nov 16 '05 #2
thanks a million, I got it working from this

though there is a new problem.
when it comes to the second case, it prints the text on the first page.

How can I solve this

still same code as above.
Nov 16 '05 #3
Hi,

"Joakim" <an*******@discussions.microsoft.com> wrote in message
news:7C**********************************@microsof t.com...
thanks a million, I got it working from this.

though there is a new problem.
when it comes to the second case, it prints the text on the first page.
I'm not sure what you mean ? Do you mean both parts are on first page and
there isn't a second page printed ? Or it prints twice the same text ?

Anyway, I'm going to write the skeleton :

public class A
{
private int nPage;

public void Print ()
{
PrintDocument pd = new PrintDocument ();
nPage = 0;
pd.PrintPage += new PrintPageEventHandler(PrintPageHandler);
pd.Print();
}

private void PrintPageHandler(object sender, PrintPageEventArgs ev)
{
switch (nPage)
{
case 0:
// print page 1
break;
case 1:
// print page 2
break;
}
++nPage;
if ( nPage < 2) ev.HasMorePages = true;
else ev.HasMorePages = false;
}
}

Do you do it like this ?

hth,
greetings

How can I solve this ?

still same code as above.

Nov 16 '05 #4
thanks again.

it works from your code.
The problem was that it printed my second page on top of the first page. Everything was just on the same page.
I think it was because of the "while" statement.

thanks a million again. finally my first "hobby" program is finished.
Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jody Gelowitz | last post by:
I am having a problem with printing selected pages. Actually, the problem isn't with printing selected pages as it is more to do with having blank pages print for those pages that have not been...
5
by: Mark Preston | last post by:
Admission first - I don't actually have a problem here but have noticed that a lot of people have been asking similar questions and getting very varied answers. What I've done is to sort of...
4
by: Jamey Shuemaker | last post by:
I've been looking for a way to do a duplex print job without a duplex printer. I reviewed some old posts about printing odd pages and found that most of them led to KB article 101075 or an export...
3
by: Tim | last post by:
Hi, I am creating my own method for printing. I am using PrintDocument and cycling through the data and creating new pages as neccessary. My question is, how can I know that total number of...
4
by: Arif | last post by:
I C# code prints very slow as compared to a third party barcode printing software. That software prints approximately 10 labels in 2 seconds while my C# code prints 10 labels in 5 to 6 seconds. And...
6
by: Bill | last post by:
Hi I am trying to get my listbox items to print if they stream past the one page mark. my code is working for one page of information (if the e.hasmorepages) is not there. But I am having...
6
by: Siv | last post by:
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...
0
by: John Smith | last post by:
Hello, I have 7 different crystal reports that need to be collated. Since I want to end up with a page of each (which all together make a single report), I created a blank main report and then...
8
by: Neo Geshel | last post by:
Greetings. BACKGROUND: My sites are pure XHTML 1.1 with CSS 2.1 for markup. My pages are delivered as application/xhtml+xml for all non-MS web clients, and as text/xml for all MS web...
2
by: deepakfordotnet | last post by:
Hi, First of all let me confess that I could not get the solution to the same problem from an earlier post Printing :by Mr.Richard MSL (dated September 24th 2006) working. (Replied by Mr.Walter...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.