Jump to content

[Resolvido] Botão Imprimir


Mica

Recommended Posts

boas tardes.. eu tou a trabalhar em visual basic 2008 e queria criar um botao imprimir...

eu encontrei o seguinte codigo

Private Sub ButtonImprimir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonImprimir.Click
Dim clidocument As Drawing.Printing.PrintDocument
clidocument = New Drawing.Printing.PrintDocument()
clidocument.DocumentName = "clientes"

AddHandler clidocument.PrintPage, AddressOf Me.Imprimirclientes

Dim savedposition As Integer = clienteCManager.Position
dlgvisualizar.document = clidocument
dlgvisualizar.showdialog()
clidocument.Dispose()
clienteCManager.Position = savedposition

End Sub


Private Sub Imprimirclientes(ByVal sender As Object, ByVal e As Drawing.Printing.PrintPageEventArgs)
Dim MyPen As Pen = New Pen(Color.Black, 3)
e.Graphics.DrawRectangle(MyPen, e.MarginBounds.X, e.MarginBounds.Y, 450, 480)
Dim MyFont As Font = New Font("Arial", 12, FontStyle.Bold)
Dim s As String = My.Settings.fotosclientes.ToString
Dim SSize As SizeF = e.Graphics.MeasureString(s, MyFont)

e.Graphics.DrawString(s, MyFont, Brushes.Black, e.MarginBounds.X + CInt(0.5 * (450 - SSize.Width)), e.MarginBounds.Y + 15) '
e.HasMorePages = False
MyFont = New Font("Arial", 11)

Dim y As Integer = e.MarginBounds.Y + 600
s = TextBox2.Text + " " + TextBox3.Text
SSize = e.Graphics.MeasureString(3, MyFont)
e.Graphics.DrawString(3, MyFont, Brushes.Black, e.MarginBounds.X + CInt(0.5 * (450 - SSize.Width)), y)
y += CInt(MyFont.GetHeight(e.Graphics))

SSize = e.Graphics.MeasureString(3, MyFont)
e.Graphics.DrawString(3, MyFont, Brushes.Black, e.MarginBounds.X + CInt(0.5 * (450 - SSize.Width)), y)

End Sub

mas so que da erro alguem sabe o que pode ser ou sabe outro tipo de codigo para fazer o butao

Edited by jpaulino
Formato o código
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.