Jump to content

Imprimir ListView


startuga
Go to solution Solved by startuga,

Recommended Posts

http://img15.imageshack.us/img15/8258/sysx.jpg

O que queria mesmo era imprimir(para impressora) a informação contida na listsview das "informações".

Já pesquisei na net mas não encontrei informação consistente :c

Em 26/05/2013 às 16:45, bioshock disse:

Fantástico obrigado, acho que esse link solucionou o meu problema!

Obrigado

Link to comment
Share on other sites

  • Solution

Obrigado pessoal acabei agora mesmo de conseguir resolver este problema, ficando o mesmo a funcionar com o seguinte código:

   Private Propriedades, Valor As String
   Private Sub RelatorioInfo()
    Dim printIt As New PrintDocument
    Dim printPreview As New PrintPreviewDialog
    printPreview.Document = printIt
    AddHandler printIt.PrintPage, AddressOf printIt_PrintPage
    Clipboard.SetImage(My.Resources.Phoenix_logo)
    printPreview.ShowDialog()
   End Sub
   Private Sub printIt_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs)
    Dim i, x As Integer
    Dim item As ListViewItem
    x = 0
    e.Graphics.DrawImage(Clipboard.GetImage, 150, -100, 550, 500)
    Dim rect As New Rectangle(0, 400, 900, 800)
    e.Graphics.DrawRectangle(Pens.Gray, rect)
    e.Graphics.DrawString("Propriedades: ", New Font("Verdana", 16, FontStyle.Bold), Brushes.Black, 40, 350)
    e.Graphics.DrawString("Valor: ", New Font("Verdana", 16, FontStyle.Bold), Brushes.Black, 417, 350)
    For i = 0 To lsvProperties.Items.Count - 1
	    item = lsvProperties.Items(i)
	    If Not String.IsNullOrEmpty(item.SubItems(1).Text) Then
		    e.Graphics.DrawString(item.SubItems(0).Text, New Font("Verdana", 11, FontStyle.Regular), Brushes.Black, 117, 402 + (x * 20))
		    e.Graphics.DrawString(item.SubItems(1).Text, New Font("Verdana", 11, FontStyle.Regular), Brushes.Black, 417, 402 + (x * 20))
		    x = x + 1
	    End If
    Next
    'data do doc
    e.Graphics.DrawString(Date.Now, New Font("Verdana", 16, FontStyle.Bold), Brushes.Black, 525, 1120)
   End Sub
   Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    RelatorioInfo()
   End Sub
End Class
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.