Visual Basic.NET - Ejemplo imprimir

 
Vista:

Ejemplo imprimir

Publicado por Xi0N (19 intervenciones) el 11/11/2006 13:02:58
Buenas, necesito que alguien me pase un codigo esta vez de ejemplo de como imprimir.
Prefiero un ejemplo ya hecho para aclararme mejor, ya que no es la primera vez que intento entender como hacerlo y me parece bastante complicado.
Os agradeceria cualquier ayuda que me podais proporcionar.

Gracias!
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Ejemplo imprimir

Publicado por Harold (411 intervenciones) el 13/11/2006 10:31:30
'Necesitas un ( printdocument1 y prinpreviewdialog1)
'propiedad document
prinpreviewdialog1.document=printdocument1

Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim linesPerPage As Single = 0
Dim yPos As Single = 0
Dim leftMargin As Single = 30 'e.MarginBounds.Left
Dim topMargin As Single = e.MarginBounds.Top - 50
Dim line As String = Nothing
linesPerPage = e.MarginBounds.Height / printFont.GetHeight(e.Graphics)

Dim Fil, Col As Int32
Dim LString As String = ""
LString = LString & "Documento interno del almacén " & vbCrLf & vbCrLf & vbCrLf & vbCrLf
LString = LString & " UBICACIONES DE LOTES (PREPARACION DE PEDIDOS) " & vbCrLf & vbCrLf & vbCrLf & vbCrLf
LString = LString & "Pedido de Venta:" & txtIdPedido.Text & " Fecha:" & Today & vbCrLf & vbCrLf & vbCrLf
LString = LString & "Cant CodArt Articulo Lote Estante Posición" & vbCrLf & _
"------------------------------------------------------------------------------------------------" & vbCrLf & vbCrLf
count = 0
For Fil = 0 To dgvCargando.Rows.Count - 1
For Col = 0 To dgvCargando.Columns.Count - 1
If Col = 3 Or Col = 5 Or Col = 6 Or Col = 7 Then
GoTo sig
Else
Call RellenarEsp(dgvCargando.Item(Col, Fil).Value.ToString, Col)
If Col < 9 Then
LString = LString & ncadena & Space(1)
Else
LString = LString & ncadena & vbCrLf
End If
End If
sig:
Next
count += 1
Next
yPos = topMargin + (count * printFont.GetHeight(e.Graphics))
e.Graphics.DrawString(LString, printFont, Brushes.Black, leftMargin, yPos, New StringFormat())
If Not (line Is Nothing) Then
e.HasMorePages = True
Else
e.HasMorePages = False
End If
End Sub

Private Sub lnkPrint_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles lnkPrint.LinkClicked
If dgvCargando.Rows.Count > 0 Then
Try
printFont = New Font("Courier new", 9)
'PrintDocument1.Print()
PrintPreviewDialog1.Width = 600
PrintPreviewDialog1.ShowDialog()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End If
End Sub
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar