Results 1 to 15 of 15

Thread: [2008]Print Entire Form

  1. #1

    Thread Starter
    Frenzied Member CoachBarker's Avatar
    Join Date
    Aug 2007
    Location
    Central NY State
    Posts
    1,121

    Question [2008]Print Entire Form

    I have a user who wants to print the form that is on the screen(the entire form not just the data) on the click of a button, is there a quick and easy way to capture it and print it. Kind of like a screen shot?

    I suggested that they could just do alt/printscreen and capture the form that way and print it but they want it all to be done from a print button for them.
    Thanks
    CoachBarker

    Code Bank Contribution
    Login/Manage Users/Navigate Records
    VB.Net | C#

    Helpful Links: VB.net Tutorial | C Sharp Tutorial | SQL Basics

  2. #2
    PowerPoster
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    2,148

    Re: [2008]Print Entire Form


  3. #3
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Re: [2008]Print Entire Form

    Hi,

    You can try this:

    vb Code:
    1. PrintForm1.PrintAction = Printing.PrintAction.PrintToPrinter
    2. PrintForm1.Print(Me, ClientAreaOnly)
    3. Me.Refresh

    Wkr,

    sparrow1
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

  4. #4

    Thread Starter
    Frenzied Member CoachBarker's Avatar
    Join Date
    Aug 2007
    Location
    Central NY State
    Posts
    1,121

    Re: [2008]Print Entire Form

    I added the Print Component and just tried it on a sample form, I think I will have to tweak it some to make the form fit on one page though. I still have to do it in C# but that shouldn't take long. Will post back if I have any problems.
    Thanks
    CoachBarker

    Code Bank Contribution
    Login/Manage Users/Navigate Records
    VB.Net | C#

    Helpful Links: VB.net Tutorial | C Sharp Tutorial | SQL Basics

  5. #5
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Re: [2008]Print Entire Form

    Hi,

    For C# I think it's this:

    vb Code:
    1. {
    2.      PrintForm1.PrintAction = Printing.PrintAction.PrintToPrinter;
    3.      PrintForm1.Print(this, ClientAreaOnly);
    4.      this.Refresh();
    5.  }

    Hope it helps,

    sparrow1
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

  6. #6

    Thread Starter
    Frenzied Member CoachBarker's Avatar
    Join Date
    Aug 2007
    Location
    Central NY State
    Posts
    1,121

    Re: [2008]Print Entire Form

    It doesn't like "ClientAreaOnly" or any type of parameters. To set a form to print in Landscape do I need to use another Print Dialog, and combine the properties?

    It also doesn't like Full Window to get the whole form.
    Thanks
    CoachBarker

    Code Bank Contribution
    Login/Manage Users/Navigate Records
    VB.Net | C#

    Helpful Links: VB.net Tutorial | C Sharp Tutorial | SQL Basics

  7. #7
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Re: [2008]Print Entire Form

    Hi,

    Did you downloaded and installed the print component like Merion suggested.
    Then it should work.

    Wkr,

    sparrow1
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

  8. #8

    Thread Starter
    Frenzied Member CoachBarker's Avatar
    Join Date
    Aug 2007
    Location
    Central NY State
    Posts
    1,121

    Re: [2008]Print Entire Form

    Oh yes I did, If I just do this;

    Code:
    private void btnPrint_Click(object sender, EventArgs e)
    {
        printForm1.PrintAction = PrintAction.PrintToPreview;
        printForm1.Print(); 
        this.Refresh();
    }
    It prints the form with no problem, but when I try to add any parameters it doesn't like them. But I do need to Print the form in a landscape style. I dragged the pageSetupDialog onto the form and played with the settings, I asssume I need to use mutiple dialogs to get the results I need?
    Thanks
    CoachBarker

    Code Bank Contribution
    Login/Manage Users/Navigate Records
    VB.Net | C#

    Helpful Links: VB.net Tutorial | C Sharp Tutorial | SQL Basics

  9. #9
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Re: [2008]Print Entire Form

    Hi,

    After a search I found that you can't use dialogs.
    But however you can find some proper information in the next link:

    http://www.4d.com/docs/CMU/CMU00005.HTM

    Hope it helps,

    sparrow1
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

  10. #10
    PowerPoster
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    2,148

    Re: [2008]Print Entire Form

    You can set the PrintForm..::.PrinterSettings property

  11. #11

    Thread Starter
    Frenzied Member CoachBarker's Avatar
    Join Date
    Aug 2007
    Location
    Central NY State
    Posts
    1,121

    Re: [2008]Print Entire Form

    Thanks I will have a look at it and see what I can put together.
    Thanks
    CoachBarker

    Code Bank Contribution
    Login/Manage Users/Navigate Records
    VB.Net | C#

    Helpful Links: VB.net Tutorial | C Sharp Tutorial | SQL Basics

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

    Re: [2008]Print Entire Form

    If you just follow Intellisense it tells you what to use. If you haven't added a 'using' directive to import the relevant namespace then Intellisense will display the fully qualified name of the enumeration and then you get to choose the value you want:
    csharp Code:
    1. this.printForm1.Print(this, Microsoft.VisualBasic.PowerPacks.Printing.PrintForm.PrintOption.ClientAreaOnly);
    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

  13. #13

    Thread Starter
    Frenzied Member CoachBarker's Avatar
    Join Date
    Aug 2007
    Location
    Central NY State
    Posts
    1,121

    Re: [2008]Print Entire Form

    I did add this as a using statement at the top of the form

    using Microsoft.VisualBasic.PowerPacks.Printing;
    Thanks
    CoachBarker

    Code Bank Contribution
    Login/Manage Users/Navigate Records
    VB.Net | C#

    Helpful Links: VB.net Tutorial | C Sharp Tutorial | SQL Basics

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

    Re: [2008]Print Entire Form

    Then Intellisense will help you to produce this:
    csharp Code:
    1. this.printForm1.Print(this, PrintForm.PrintOption.ClientAreaOnly);
    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

  15. #15
    New Member
    Join Date
    Mar 2010
    Posts
    1

    Re: [2008]Print Entire Form

    Ok I have the same problem except for me it will only print the top of the form and that is it. My code is the following if anyone can help?

    Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Me.Focus()
    Me.Show()
    Me.PrintForm1.Print(Me, Microsoft.VisualBasic.PowerPacks.Printing.PrintForm.PrintOption.ClientAreaOnly)
    PrintForm1.PrintAction = Printing.PrintAction.PrintToPrinter
    PrintForm1.Print(Me, PowerPacks.Printing.PrintForm.PrintOption.ClientAreaOnly)
    Me.Refresh()

    End Sub
    End Class

    All this does is print the top edge of my form. please help as this is my last problem with my program

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