Thanks for the reply Samuel, but after more searching, I finally found
someone else's code I used as an example.
Private Sub mnuMailLabel_Cl ick(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles mnuMailLabel.Cl ick
Dim doc As PrintDocument = New PrintDocument
Dim printer As PrintDialog = New PrintDialog
printer.Documen t = doc
printer.Printer Settings.Printe rName = My.Settings.MPr inter
printer.Documen t.DefaultPageSe ttings.PaperSiz e = New
Printing.PaperS ize(Printing.Pa perKind.Custom, 350, 100)
AddHandler doc.PrintPage, AddressOf PrintPageHandle r
doc.Print()
End Sub
Private Sub PrintPageHandle r(ByVal sender As Object, ByVal e As
PrintPageEventA rgs)
Dim canvas As Graphics = e.Graphics
Dim _font As Font = New Font("Tahoma", 10)
Dim _brush = Brushes.Black
Dim PrintString As String
PrintString = txtFName.Text & " "
If Trim(txtMI.Text ) <"" Then
PrintString = PrintString & VB.Left(txtMI.T ext, 1) & " "
End If
PrintString = PrintString & txtLName.Text & vbCrLf &
txtAddress.Text & vbCrLf & txtCity.Text & ", " & txtState.Text & " " &
txtZip.Text
canvas.DrawStri ng(PrintString, _font, _brush, 0, 0)
End Sub
The line:
printer.Documen t.DefaultPageSe ttings.PaperSiz e = New
Printing.PaperS ize(Printing.Pa perKind.Custom, 350, 100)
was what I couldn't quite figure out how to do. This code works fine
in my program.
On Mon, 17 Jul 2006 18:44:33 +0100, "Samuel Shulman"
<sa************ @ntlworld.comwr ote:
>Not sure but the following may help you
'Set the page settings
Dim obPage As New PageSettings
obpage.PaperSi ze.Kind = 'PaperKind Enumeration value
'Assign theis object to the PrintDocument.D ocument member
You may set it to custom size (it is a value in the enum) and then set it to
the required size
hth,
Samuel
"Kevin" <ke****@cfl.rr. comwrote in message
news:70******* *************** **********@4ax. com...
>In my VB2005 Windows Forms program I want to be able to click a button
and have my Dot Matrix printer print one 15/16 x 3 1/2 address label
from continuous forms.
I'm trying to use a PrintDocument, but don't know how to set up the
page size to be only one label.