|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Print the content of a listview"Descripteur non valide" and i don't know why. Following the part of my code : Friend WithEvents Papier As System.Drawing.Printing.PrintDocument Me.Papier = New System.Drawing.Printing.PrintDocument Private Sub cmdPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdPrint.Click Try Papier.Print() Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Critical, "Problème d'impression !") End Try End Sub Private Sub Papier_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles Papier.PrintPage e.Graphics.DrawString(Me.Text, New Font("Helvetica narrow", 12, FontStyle.Bold), Brushes.Black, 160, 4) e.Graphics.DrawString("Section", New Font("Helvetica narrow", 10, FontStyle.Bold), Brushes.Black, 14, 50) e.Graphics.DrawString("Rubrique", New Font("Helvetica narrow", 10, FontStyle.Bold), Brushes.Black, 180, 50) ...... Hi Bernalin,
I changed your code slightly and it works for me. Public Class Form1 Friend WithEvents Papier As New System.Drawing.Printing.PrintDocument Private Sub cmdPrint_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles cmdPrint.Click Try Papier.Print() Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Critical, "Problème d'impression!" End Try End Sub Private Sub Papier_PrintPage(ByVal sender As Object, _ ByVal e As System.Drawing.Printing.PrintPageEventArgs) _ Handles Papier.PrintPage e.Graphics.DrawString(Me.Text, New Font("Helvetica narrow", _ 12, FontStyle.Bold), Brushes.Black, 160, 4) e.Graphics.DrawString("Section", New Font("Helvetica narrow", _ 10, FontStyle.Bold), Brushes.Black, 14, 50) e.Graphics.DrawString("Rubrique", New Font("Helvetica narrow", _ 10, FontStyle.Bold), Brushes.Black, 180, 50) End Sub End Class Hope this helps. Martin. Show quoteHide quote "Bernalin" <Berna***@discussions.microsoft.com> wrote in message news:A5590B35-8CA6-4FF2-B1BD-B450997E269B@microsoft.com... > The Print() method used in my vb .net 2003 program abort with a > "Descripteur non valide" and i don't know why. > > Following the part of my code : > > Friend WithEvents Papier As System.Drawing.Printing.PrintDocument > Me.Papier = New System.Drawing.Printing.PrintDocument > Private Sub cmdPrint_Click(ByVal sender As System.Object, ByVal e As > System.EventArgs) Handles cmdPrint.Click > Try > Papier.Print() > Catch ex As Exception > MsgBox(ex.Message, MsgBoxStyle.Critical, "Problème d'impression > !") > End Try > End Sub > > Private Sub Papier_PrintPage(ByVal sender As Object, ByVal e As > System.Drawing.Printing.PrintPageEventArgs) Handles Papier.PrintPage > e.Graphics.DrawString(Me.Text, New Font("Helvetica narrow", 12, > FontStyle.Bold), Brushes.Black, 160, 4) > e.Graphics.DrawString("Section", New Font("Helvetica narrow", 10, > FontStyle.Bold), Brushes.Black, 14, 50) > e.Graphics.DrawString("Rubrique", New Font("Helvetica narrow", 10, > FontStyle.Bold), Brushes.Black, 180, 50) > ..... > |
|||||||||||||||||||||||