Buongiorno,
io uso questo codice per stampare Crystal report ma stampa sempre stampante predefinito
su txtstampante.text se lo metto nome del stampante non prende.
potete aiutarmi
grazie,
Private Sub btnstampa_Click(sender As Object, e As EventArgs) Handles btnstampa.Click
Try
Dim cryRpt As New ReportDocument
Dim crtableLogoninfos As New TableLogOnInfos
Dim crtableLogoninfo As New TableLogOnInfo
Dim crConnectionInfo As New ConnectionInfo
Dim CrTables As Tables
Dim CrTable As Table
cryRpt.Load("C:\Gestione Magazzino\Report\rpt_etichetta_daspedire.rpt")
With crConnectionInfo
.ServerName = My.Settings.mServer
.DatabaseName = My.Settings.mDBname
.UserID = My.Settings.mUsername
.Password = My.Settings.mPassword
End With
CrTables = cryRpt.Database.Tables
For Each CrTable In CrTables
crtableLogoninfo = CrTable.LogOnInfo
crtableLogoninfo.ConnectionInfo = crConnectionInfo
CrTable.ApplyLogOnInfo(crtableLogoninfo)
Next
cryRpt.Load("C:\Gestione Magazzino\Report\rpt_etichetta_daspedire.rpt")
CrystalReportViewer1.ReportSource = cryRpt
CrystalReportViewer1.SelectionFormula = "{DaSpedire.codicespedizione}='" & txtcodspedizione.Text.ToString() & "'"
CrystalReportViewer1.Refresh()
CrystalReportViewer1.RefreshReport()
cryRpt.PrintOptions.PrinterName = txtstampante.Text.ToString()
cryRpt.PrintToPrinter(txtcopie.Text, False, 0, 0)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub