Results 1 to 7 of 7

Thread: Please help! Code behind for Print

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2013
    Location
    Ireland
    Posts
    25

    Unhappy Please help! Code behind for Print

    Hi,

    I have a report that I need to print after a sale has completed. I am having issues with the length and printing when using PrintForm and PrintDocument components however if I right click and select Print from the list the report prints perfectly. Is there any way that I could write code in my form load event that would imitate the right click print?

    Ive been struggling with this part of my project for ages now and the whole thing is now way behind schedule.

    Any help would be greatly appreciated.

    Thanks!

  2. #2
    Member
    Join Date
    Aug 2012
    Location
    Nottingham, UK
    Posts
    44

    Re: Please help! Code behind for Print

    Please post the code you are having problems with so we can try to assist. Thanks
    ~ TheMeq ~
    If I helped in anyway, please hit the star and send me some rep! Thanks

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Nov 2013
    Location
    Ireland
    Posts
    25

    Re: Please help! Code behind for Print

    Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click

    With Me.PrintForm1
    .PrintAction = Printing.PrintAction.PrintToPrinter

    Dim MyMargins As New Margins
    With MyMargins
    .Left = 0
    .Right = 0
    .Top = 0
    .Bottom = 0
    End With
    .PrinterSettings.DefaultPageSettings.Margins = MyMargins
    .Print(Me, PowerPacks.Printing.PrintForm.PrintOption.Scrollable)

    End With

  4. #4
    PowerPoster Radjesh Klauke's Avatar
    Join Date
    Dec 2005
    Location
    Sexbierum (Netherlands)
    Posts
    2,244

    Re: Please help! Code behind for Print



    If you found my post helpful, please rate it.

    Codebank Submission: FireFox Browser (Gecko) in VB.NET, Load files, (sub)folders treeview with Windows icons

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Nov 2013
    Location
    Ireland
    Posts
    25

    Re: Please help! Code behind for Print

    I know that but what im asking is for help on coding right click and print?

    thanks

  6. #6
    Registered User
    Join Date
    Oct 2013
    Posts
    2

    Re: Please help! Code behind for Print

    use the following code, it helps you to print the invoice to printer directly

    Dim rptSalesPF As New rptSalesPrintedForm
    Dim doc As New Drawing.Printing.PrintDocument

    doc.PrinterSettings.PrinterName = prnName
    rptSalesPF.PrintOptions.PrinterName = prnName
    rptSalesPF.PrintOptions.CustomPaperSource = doc.PrinterSettings.PaperSources.Item(tray)

    rptSalesPF.PrintToPrinter(1, False, 0, 0)

    hope this will help you

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Nov 2013
    Location
    Ireland
    Posts
    25

    Re: Please help! Code behind for Print

    Thanks for your reply. I'll try it and let you know.

    thanks
    Kerrie

Tags for this Thread

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