Results 1 to 6 of 6

Thread: Long DataGridView - print

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2010
    Posts
    83

    Long DataGridView - print

    I have very long DataDridView which I need to print.
    DataGridView contains header and only one row , but may contains 6 to 180 columns.
    I would like to print on only one page in multiple lines (depending on the size of my datagridview).
    Does someone, somewhere already has an example of how to do it?
    Thanks in advance.
    Onenew

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,423

    Re: Long DataGridView - print

    here's an example:
    Attached Files Attached Files

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Long DataGridView - print

    I haven't looked a Paul's example but there is a thread by Merrion in the VB.NET CodeBank forum that contains classes for printing DataGrid and DataGridView controls.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Oct 2010
    Posts
    83

    Re: Long DataGridView - print

    Thanks, Paul,
    I think, it will be a solution if I manage to set the "landscape" orientation, and margins for printing. Is it possible to do this?
    Onenew

  5. #5
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,423

    Re: Long DataGridView - print

    to change the orientation:

    vb Code:
    1. PrintDocument1.DefaultPageSettings.Landscape = True

    as for the margins, i didn't use them, but exactly where each printer prints the same location seems to vary from printer to printer, so you may need to provide some method of adjustment

  6. #6
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,423

    Re: Long DataGridView - print

    Quote Originally Posted by jmcilhinney View Post
    I haven't looked a Paul's example but there is a thread by Merrion in the VB.NET CodeBank forum that contains classes for printing DataGrid and DataGridView controls.
    my example is a one off custom print routine, specifically tailored for this situation. merrions dgv printing is a general method + would print this one row + header row over several pages

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