Impression d'une listview en vb.net
Fermé
pierre42
Messages postés
17
Date d'inscription
mercredi 12 octobre 2005
Statut
Membre
Dernière intervention
21 décembre 2006
-
14 nov. 2006 à 11:40
said369 - 8 janv. 2008 à 23:05
said369 - 8 janv. 2008 à 23:05
A voir également:
- Impression d'une listview en vb.net
- Spouleur d'impression - Guide
- Impression livret a5 - Guide
- Logiciel impression photo - Télécharger - Albums photo
- Impression miroir word - Guide
- Impression ecran samsung - Guide
1 réponse
salut c'est said
Dans la classe de la forme ou se trouve ta listviewqu'on suppose qu'elle se nomme listview1 tu ajoute le code suivant aprés "public class form1":
Dim memoryImage As Bitmap
Private Declare Function BitBlt Lib "gdi32.dll" Alias "BitBlt" (ByVal _
hdcDest As IntPtr, ByVal nXDest As Integer, ByVal nYDest As _
Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal _
hdcSrc As IntPtr, ByVal nXSrc As Integer, ByVal nYSrc As Integer, _
ByVal dwRop As System.Int32) As Long
Private Sub CaptureScreen()
Dim mygraphics As Graphics = Me.listview1.CreateGraphics()
Dim s As Size = New Size(353, 274)
memoryImage = New Bitmap(s.Width, s.Height, mygraphics)
Dim memoryGraphics As Graphics = Graphics.FromImage(memoryImage)
Dim dc1 As IntPtr = mygraphics.GetHdc
Dim dc2 As IntPtr = memoryGraphics.GetHdc
BitBlt(dc2, 0, 0, Me.ClientRectangle.Width, _
Me.ClientRectangle.Height, dc1, 0, 0, 13369376)
mygraphics.ReleaseHdc(dc1)
memoryGraphics.ReleaseHdc(dc2)
End Sub
puis dans l'évenement PrintPage du controle printdocument1 on ajoute:
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
e.Graphics.DrawImage(memoryImage, 29, 40, 450, 350)
End Sub
enfin dans la sub du boutton(imprimer) qui déclenche l'évenement clic on fait:
Private Sub imprimer_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
CaptureScreen()
PrintDocument1.Print()
End Sub
Dans la classe de la forme ou se trouve ta listviewqu'on suppose qu'elle se nomme listview1 tu ajoute le code suivant aprés "public class form1":
Dim memoryImage As Bitmap
Private Declare Function BitBlt Lib "gdi32.dll" Alias "BitBlt" (ByVal _
hdcDest As IntPtr, ByVal nXDest As Integer, ByVal nYDest As _
Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal _
hdcSrc As IntPtr, ByVal nXSrc As Integer, ByVal nYSrc As Integer, _
ByVal dwRop As System.Int32) As Long
Private Sub CaptureScreen()
Dim mygraphics As Graphics = Me.listview1.CreateGraphics()
Dim s As Size = New Size(353, 274)
memoryImage = New Bitmap(s.Width, s.Height, mygraphics)
Dim memoryGraphics As Graphics = Graphics.FromImage(memoryImage)
Dim dc1 As IntPtr = mygraphics.GetHdc
Dim dc2 As IntPtr = memoryGraphics.GetHdc
BitBlt(dc2, 0, 0, Me.ClientRectangle.Width, _
Me.ClientRectangle.Height, dc1, 0, 0, 13369376)
mygraphics.ReleaseHdc(dc1)
memoryGraphics.ReleaseHdc(dc2)
End Sub
puis dans l'évenement PrintPage du controle printdocument1 on ajoute:
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
e.Graphics.DrawImage(memoryImage, 29, 40, 450, 350)
End Sub
enfin dans la sub du boutton(imprimer) qui déclenche l'évenement clic on fait:
Private Sub imprimer_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
CaptureScreen()
PrintDocument1.Print()
End Sub