Results 1 to 5 of 5

Thread: Visual Basic Net, Printing Form

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2019
    Posts
    57

    Visual Basic Net, Printing Form

    I am creating a report by dynamically adding populated datagridview's of various lengths to a Form.

    I would like to print the output and fit it to 8-1/2 X 11 pages

    Among the challenges is detecting when a datagridview is going to be split between two pages and either deciding to start a new page at the beginning of the datagridview or letting it run on.

    Is there a way that I should be placing and sizing the datagridview's on my form to accommodate fitting to a page width?

    Then of course I need to know how to use the;
    printDocument1 As New PrintDocument
    appropriately

    Thanks in advance
    Richard

  2. #2
    Hyperactive Member Delaney's Avatar
    Join Date
    Nov 2019
    Location
    Paris, France
    Posts
    345
    The best friend of any programmer is a search engine
    "Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)

  3. #3
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    23,408

    Re: Visual Basic Net, Printing Form

    Here's my multi-page dgv printing code...

    http://www.scproject.biz/DataGridView%20Printing.php

  4. #4

    Thread Starter
    Member
    Join Date
    Nov 2019
    Posts
    57

    Re: Visual Basic Net, Printing Form

    Thank you for the code samples.
    Unfortunately I have a form with many datagridviews' and other objects such as labels and charts that scroll down the length of the form.

    I am trying to find a way to parse the form into standard pages and pr

  5. #5
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,468

    Re: Visual Basic Net, Printing Form

    Quote Originally Posted by Richard Friedman View Post
    I am trying to find a way to parse the form into standard pages
    There is no magic way to do that. It's up to you to determine the logic, which will be specific to each scenario, and then write code to implement it. As always, think about how you would do it manually first to get the general logic, then formalise it into an algorithm and then write code to implement that algorithm. You may not be able to use .paul.'s code as is if you're printing more than just a DataGridView but you can still use the relevant parts of the code in your own.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width