I want to print receipts without showing the print preview window. Is it possible to have it print to the default printer connected to the pc without print preview?
This is my current code:
Private Sub BTPRINT_Click(sender As Object, e As EventArgs) Handles BTPRINT.Click
Dim dt As New DataTable
With dt
.Columns.Add("Articulo")
.Columns.Add("Cantidad")
.Columns.Add("Precio")
End With
For Each dgr As DataGridViewRow In Me.DataGridView1.Rows
dt.Rows.Add(dgr.Cells(0).Value, dgr.Cells(1).Value, dgr.Cells(2).Value)
Next
Dim reportdocument As CrystalDecisions.CrystalReports.Engine.ReportDocument
reportdocument = New CrystalReport2
reportdocument.SetDataSource(dt)
Form3.CrystalReportViewer1.ReportSource = reportdocument
Form3.ShowDialog()
Form3.Dispose()
End Sub
CodePudding user response:
This was extremly simple.
I removed:
Form3.ShowDialog()
Form3.Dispose()
and swapped it with:
reportdocument.PrintToPrinter(0, False, 1, 1)