Results 1 to 4 of 4

Thread: HoW can i set default printer for crystalreport

  1. #1

    Thread Starter
    Fanatic Member manhit45's Avatar
    Join Date
    May 2009
    Location
    Ha noi - Viet Nam
    Posts
    826

    HoW can i set default printer for crystalreport

    I want to set default printer in crystalreport.
    Because, every i print , i have to choose printer before printing.
    --***----------***-----

    If i help you please rate me.

    Working with Excel * Working with String * Working with Database * Working with array *

    K51 ĐH BÁCH KHOA HÀ NỘI - Khoa CNTT pro.

  2. #2
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: HoW can i set default printer for crystalreport

    Are you printing by clicking on the print button in the crystalreportviewer control?
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

  3. #3

    Thread Starter
    Fanatic Member manhit45's Avatar
    Join Date
    May 2009
    Location
    Ha noi - Viet Nam
    Posts
    826

    Re: HoW can i set default printer for crystalreport

    Quote Originally Posted by stanav View Post
    Are you printing by clicking on the print button in the crystalreportviewer control?
    Yes. I can manually operate setup printer default by in PRINTER AND FAXS.
    But i want to set by code ?
    --***----------***-----

    If i help you please rate me.

    Working with Excel * Working with String * Working with Database * Working with array *

    K51 ĐH BÁCH KHOA HÀ NỘI - Khoa CNTT pro.

  4. #4
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: HoW can i set default printer for crystalreport

    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:
    1. 'Create your own print button
    2.     Private WithEvents PrintReportToolStripButton As New ToolStripButton()
    3.  
    4.     'In form load, find the original print button on th report viewer and replace it with your own button
    5.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    6.        
    7.         For Each ctrl As Control In Me.CrystalReportViewer1.Controls
    8.             If TypeOf ctrl Is ToolStrip Then
    9.                 Dim ts As ToolStrip = DirectCast(ctrl, ToolStrip)
    10.                 If ts.Items.Count > 1 Then
    11.                     Me.PrintReportToolStripButton.Image = ts.Items(1).Image
    12.                     ts.Items.RemoveAt(1)
    13.                     ts.Items.Insert(1, Me.PrintReportToolStripButton)
    14.                 End If
    15.             End If
    16.         Next
    17.        
    18.     End Sub
    19.  
    20.     'Handling your own print button click event
    21.     Private Sub PrintReportToolStripButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles PrintReportToolStripButton.Click
    22.         'Assign a printer to your report document
    23.         Me.reportDocument1.PrintOptions.PrinterName = "put the name of the printer you want to use here"
    24.         'Then print the document
    25.         Me.reportDocument1.PrintToPrinter(1, True, 1, 1)
    26.     End Sub
    Last edited by stanav; Jan 11th, 2010 at 10:40 AM.
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

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