printing two pages

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Joakim Olsson

    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++

  • BMermuys

    #2
    Re: printing two pages

    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" <joakim.olsson@ mail.com> wrote in message
    news:D4D732B1-8821-40A9-B1F6-ABFA4A373B6F@mi crosoft.com...[color=blue]
    > 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[/color]
    on the two pages, or sometimes the second page over the first page.[color=blue]
    >
    > 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++;
    >[/color]


    Comment

    • Joakim

      #3
      Re: printing two pages

      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.

      Comment

      • BMermuys

        #4
        Re: printing two pages

        Hi,

        "Joakim" <anonymous@disc ussions.microso ft.com> wrote in message
        news:7C7FF5CA-394F-4B12-96FB-96826E8FC7E7@mi crosoft.com...[color=blue]
        > 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.[/color]

        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 PrintPageEventH andler(PrintPag eHandler);
        pd.Print();
        }

        private void PrintPageHandle r(object sender, PrintPageEventA rgs 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
        [color=blue]
        >
        > How can I solve this ?
        >
        > still same code as above.[/color]


        Comment

        • Joakim

          #5
          Re: printing two pages

          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.

          Comment

          Working...