Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Changing printer for printing pages

Reply
Thread Tools

Changing printer for printing pages

 
 
Harpreet Singh via .NET 247
Guest
Posts: n/a
 
      06-11-2004
(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>
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
brochure printing,online yearbook,printing,books printing,publishing elie Computer Support 2 11-27-2010 12:12 PM
brochure printing,online yearbook,printing,books printing,publishing elie Computer Support 0 08-21-2007 05:52 AM
brochure printing,online yearbook,printing,books printing,publishing elie Computer Support 0 08-21-2007 05:50 AM
brochure printing,online yearbook,printing,books printing,publishing elie Computer Support 0 08-21-2007 05:28 AM
brochure printing,online yearbook,printing,books printing,publishing elie Computer Support 0 08-18-2007 10:11 AM



Advertisments