473,383 Members | 1,885 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,383 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 4747
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
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.