By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,582 Members | 1,720 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,582 IT Pros & Developers. It's quick & easy.

Print the content of a listview

P: n/a
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)
......

Nov 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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.

"Bernalin" <Be******@discussions.microsoft.com> wrote in message
news:A5**********************************@microsof t.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, "Problme 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)
.....

Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.