Changing printer for printing pages

Discussion in 'ASP .Net Datagrid Control' started by Harpreet Singh via .NET 247, Jun 11, 2004.

  1. (Type your message here)
    Hi
    I am trying to print pages by giving the printer name but I amhaving some problem in printing to that printer ..The printername I give is not the default printer. When I debug the project1st time the very 1st page is printed on default printer butafter that printing works fine and I get print outs from nondefault printer which I want. If I close it and start again itagain prints the 1st page on default printer..I am not able tofind out wats happening.. My code is:

    Private Sub btnPrintSingle_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles btnPrintSingle.Click
    lblDocument.Print()
    End Sub

    Private Sub lblDocument_PrintPage(ByVal sender As System.Object,ByVal e As System.Drawing.Printing.PrintPageEventArgs) HandleslblDocument.PrintPage
    e.PageSettings.PrinterSettings.PrinterName =labelPrinter
    printLabels(e)
    End Sub

    Sub printLabels(ByVal e AsSystem.Drawing.Printing.PrintPageEventArgs)
    Dim sngPrintX As Single = e.MarginBounds.Left
    Dim sngPrintY As Single = e.MarginBounds.Top
    Dim printLine As String
    Dim myFont As System.Drawing.Font
    Dim myBarcodeFont As System.Drawing.Font
    Dim myBigfont As System.Drawing.Font

    myFont = New System.Drawing.Font("Arial", 8,Drawing.FontStyle.Regular)
    myBigfont = New System.Drawing.Font("Arial", 20,Drawing.FontStyle.Regular)
    myBarcodeFont = New System.Drawing.Font("Free 3 of 9Extended", 20, Drawing.FontStyle.Regular)
    Dim sngLineHeight As Single = myFont.GetHeight + 4
    PrintDialog1.PrinterSettings.PrinterName = labelPrinter
    printLine = "*" & printItemId & "*"
    e.Graphics.PageUnit =System.Drawing.GraphicsUnit.Document
    e.Graphics.DrawString(printLine, myBarcodeFont,System.Drawing.Brushes.Black, sngPrintX, sngPrintY)
    sngPrintY += 2 * (myBarcodeFont.GetHeight)
    printLine = printItemId
    e.Graphics.DrawString(printLine, myFont,System.Drawing.Brushes.Black, sngPrintX, sngPrintY)
    sngPrintY += 2 * sngLineHeight
    printLine = printItemDescription
    e.Graphics.DrawString(printLine, myFont,System.Drawing.Brushes.Black, sngPrintX - 10, sngPrintY)
    sngPrintY += 2 * sngLineHeight
    printLine = printItemSize
    e.Graphics.DrawString(printLine, myFont,System.Drawing.Brushes.Black, sngPrintX - 10, sngPrintY)
    sngPrintY += 2 * sngLineHeight
    printLine = printItemPrice
    e.Graphics.DrawString(printLine, myBigfont,System.Drawing.Brushes.Black, sngPrintX, sngPrintY)
    e.HasMorePages = False
    End Sub
    --------------------------------

    I have tried giving the printer name in printlabels() functionbut I have the same problem
    Any Reply is very appreciated.
    Thanks in anticipation

    From: Harpreet Singh

    -----------------------
    Posted by a user from .NET 247 (http://www.dotnet247.com/)

    <Id>WwctL2V7FEKetOW00Q16+w==</Id>
    Harpreet Singh via .NET 247, Jun 11, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. peter
    Replies:
    0
    Views:
    404
    peter
    Apr 29, 2004
  2. Amrendra Nath
    Replies:
    1
    Views:
    2,436
    Natty Gur
    Oct 21, 2003
  3. Samuel Lee
    Replies:
    0
    Views:
    511
    Samuel Lee
    Nov 11, 2003
  4. Jody Burgess
    Replies:
    2
    Views:
    546
    George Kinney
    Jul 17, 2004
  5. Replies:
    5
    Views:
    142
Loading...

Share This Page