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!
Re: Please help! Code behind for Print
Please post the code you are having problems with so we can try to assist. Thanks
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
Re: Please help! Code behind for Print
Re: Please help! Code behind for Print
I know that but what im asking is for help on coding right click and print?
thanks
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
Re: Please help! Code behind for Print
Thanks for your reply. I'll try it and let you know.
thanks
Kerrie