Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Printing - can´t print a second page

Printing - can´t print a second page

Scheduled Pinned Locked Moved C#
helptutorialquestion
8 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    naglbitur
    wrote on last edited by
    #1

    Hi there. I am having some problems printing. I made a form with some Label controls and other stuff. The problem is when I want to print, only what fits to one page gets printed out but nothing outside of the first page. For instance, a Label controls has the coordinates 65, 1650 doesn´t get printed but is shows up on screen. I know about HasMorePages but I just don´t know how to use it. I just need to be able to print out two pages, the first one is no problem but the second one is a problem, it doesn´t get printed at all :sigh: Can someone please help me? Thanks in advance, FJ

    P M 2 Replies Last reply
    0
    • N naglbitur

      Hi there. I am having some problems printing. I made a form with some Label controls and other stuff. The problem is when I want to print, only what fits to one page gets printed out but nothing outside of the first page. For instance, a Label controls has the coordinates 65, 1650 doesn´t get printed but is shows up on screen. I know about HasMorePages but I just don´t know how to use it. I just need to be able to print out two pages, the first one is no problem but the second one is a problem, it doesn´t get printed at all :sigh: Can someone please help me? Thanks in advance, FJ

      P Offline
      P Offline
      peshkunta
      wrote on last edited by
      #2

      Try this: //Set the PrintDocument object property. //This sets the pages to be printed //Gets or sets the page number from which to start printing printDocument1.PrinterSettings.FromPage = 1; //Gets or sets the page number to which to print printDocument1.PrinterSettings.ToPage = 2; //This will print 2 pages from 1 to 2. :->

      N 2 Replies Last reply
      0
      • P peshkunta

        Try this: //Set the PrintDocument object property. //This sets the pages to be printed //Gets or sets the page number from which to start printing printDocument1.PrinterSettings.FromPage = 1; //Gets or sets the page number to which to print printDocument1.PrinterSettings.ToPage = 2; //This will print 2 pages from 1 to 2. :->

        N Offline
        N Offline
        naglbitur
        wrote on last edited by
        #3

        Hi, thanks for your help. Does this mean I don´t need to set the HasMorePages property? FJ

        1 Reply Last reply
        0
        • P peshkunta

          Try this: //Set the PrintDocument object property. //This sets the pages to be printed //Gets or sets the page number from which to start printing printDocument1.PrinterSettings.FromPage = 1; //Gets or sets the page number to which to print printDocument1.PrinterSettings.ToPage = 2; //This will print 2 pages from 1 to 2. :->

          N Offline
          N Offline
          naglbitur
          wrote on last edited by
          #4

          Hi. I just tried what you suggested but the outcome is still the same:( I do not know how to use the HasMorePages property. Do you have any ideas? In the program the stuff that comes on the second page doesn´t have to appear on screen, it would be just fine to let it only be printed out after the first page which would contain what is on the screen. Any help is appreciated. FJ

          S 1 Reply Last reply
          0
          • N naglbitur

            Hi. I just tried what you suggested but the outcome is still the same:( I do not know how to use the HasMorePages property. Do you have any ideas? In the program the stuff that comes on the second page doesn´t have to appear on screen, it would be just fine to let it only be printed out after the first page which would contain what is on the screen. Any help is appreciated. FJ

            S Offline
            S Offline
            Stanciu Vlad
            wrote on last edited by
            #5

            Here is an simple ideea on how to use the HasMorePages property. Declare a global variable that rembers the current page number (optional). In your print procedure do the adecvate printing taking account of the page borders. If your drawing must go onto the next page (mening that you encountered the end of the page), set the HasMorePages to true and return from the proedure. Afther returning if the misterious procedure is setted to true the print procedure is called again with another page as an argument. Yes, in this algorithm you must take account of the page numer (or any other relating element) in order to achive a desired result. If you created an page number variable, before returning from the print method remember to increment the page. Hope this helps.

            protected internal static readonly ... and I wish the list could continue ...

            1 Reply Last reply
            0
            • N naglbitur

              Hi there. I am having some problems printing. I made a form with some Label controls and other stuff. The problem is when I want to print, only what fits to one page gets printed out but nothing outside of the first page. For instance, a Label controls has the coordinates 65, 1650 doesn´t get printed but is shows up on screen. I know about HasMorePages but I just don´t know how to use it. I just need to be able to print out two pages, the first one is no problem but the second one is a problem, it doesn´t get printed at all :sigh: Can someone please help me? Thanks in advance, FJ

              M Offline
              M Offline
              Marc 0
              wrote on last edited by
              #6

              private void Document_PrintPage(object sender, PrintPageEventArgs e){
              // Do your printing stuff here

              // If you need to print any pages after this one,
              // you set the HasMorePages property to true.
              // If this is the last one, set it it to false
              e.HasMorePages = true;
              }

              HTH! :)


              "..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.." -- Mark McCormick


              || Fold With Us! || Pensieve || VG.Net ||

              N 1 Reply Last reply
              0
              • M Marc 0

                private void Document_PrintPage(object sender, PrintPageEventArgs e){
                // Do your printing stuff here

                // If you need to print any pages after this one,
                // you set the HasMorePages property to true.
                // If this is the last one, set it it to false
                e.HasMorePages = true;
                }

                HTH! :)


                "..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.." -- Mark McCormick


                || Fold With Us! || Pensieve || VG.Net ||

                N Offline
                N Offline
                naglbitur
                wrote on last edited by
                #7

                Hi. I did try this but I couldn´t manage to make it work for some reason. I set the HasMorePages property to true after the printing code for the last item on my page. Then I added what I wanted on the second page and at the end of that code I set the HasMorePages property to false to stop the printing. Despite this my printer only prints out one page:(( What am I doing wrong? FJ

                P 1 Reply Last reply
                0
                • N naglbitur

                  Hi. I did try this but I couldn´t manage to make it work for some reason. I set the HasMorePages property to true after the printing code for the last item on my page. Then I added what I wanted on the second page and at the end of that code I set the HasMorePages property to false to stop the printing. Despite this my printer only prints out one page:(( What am I doing wrong? FJ

                  P Offline
                  P Offline
                  peshkunta
                  wrote on last edited by
                  #8

                  Check this out: http://www.devarticles.com/c/a/C-Sharp/Printing-Using-C-sharp/

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups