1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| Private Sub BtnLabel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnLabel.Click
PrintDialog1.Document = PrintDocument1
PrintDialog1.ShowDialog()
PrintPreviewDialog1.Document = PrintDialog1.Document
PrintPreviewDialog1.ShowDialog()
End Sub
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim ADroite As StringFormat = New StringFormat
Dim AGauche As StringFormat = New StringFormat
Dim ACentre As StringFormat = New StringFormat
ADroite.Alignment = StringAlignment.Far
AGauche.Alignment = StringAlignment.Near
ACentre.Alignment = StringAlignment.Center
PrintDocument1.PrinterSettings.DefaultPageSettings.Landscape = True
If CInt(LblIdClient.Text) > 0 Then
With e.Graphics
.PageUnit = GraphicsUnit.Millimeter
.DrawString(Trim(TxtNom.Text), New Font("Arial", 24, FontStyle.Regular), Brushes.Black, 37, 25, ACentre)
End With
Else
MsgBox("Il n'y a rien a imprimer", MsgBoxStyle.Exclamation)
End If
End Sub |
Partager