I want to set default printer in crystalreport.
Because, every i print , i have to choose printer before printing.
:rolleyes:
Printable View
I want to set default printer in crystalreport.
Because, every i print , i have to choose printer before printing.
:rolleyes:
Are you printing by clicking on the print button in the crystalreportviewer control?
You have to find the original print button on the report viewer control and replace it with on of your own. You then handle that button click event. In the event handler, you assign a printer to your report document and then print it. Some thing like this:
vb.net Code:
'Create your own print button Private WithEvents PrintReportToolStripButton As New ToolStripButton() 'In form load, find the original print button on th report viewer and replace it with your own button Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load For Each ctrl As Control In Me.CrystalReportViewer1.Controls If TypeOf ctrl Is ToolStrip Then Dim ts As ToolStrip = DirectCast(ctrl, ToolStrip) If ts.Items.Count > 1 Then Me.PrintReportToolStripButton.Image = ts.Items(1).Image ts.Items.RemoveAt(1) ts.Items.Insert(1, Me.PrintReportToolStripButton) End If End If Next End Sub 'Handling your own print button click event Private Sub PrintReportToolStripButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles PrintReportToolStripButton.Click 'Assign a printer to your report document Me.reportDocument1.PrintOptions.PrinterName = "put the name of the printer you want to use here" 'Then print the document Me.reportDocument1.PrintToPrinter(1, True, 1, 1) End Sub