473,387 Members | 1,483 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Print the content of a listview

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
1 2924
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, "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 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jared Frailey | last post by:
I'm new to CSS and I want to show URLs for links in parentheses when printing. Example: Given the html: <a href="http://www.google.com">Google</a> Print: Google (http://www.google.com) ...
7
by: touf | last post by:
Hi, how can we print the content of a listView or a datatable... or a text (simple information) without to use crystal report.
1
by: Shane | last post by:
When I populate a listview control from a database with the appropropriate help codes for a data field, I want to make the listview box the exact needed size to hold the list of codes and...
4
by: Samuel R. Neff | last post by:
I'm using this class to work around the ListView.Cursor bug in .NET 1.0/1.1. It fixes the bug as long as the user mouses around the client area of the listview but if the listview is in detail...
1
by: Jan | last post by:
Hello everyone, I've got the following problem. I filled a listview like this: Counter = 0 Do Until FileIn(Counter) = "" strItem = FileIn(Counter).Split(";") ListView1.Items.Add(strItem(0))...
2
by: Terry Olsen | last post by:
Does anyone have an example of how I could print a ListView control? It'd sure be easier to do this than to try to format the output in DrawStrings... Thanks.
3
by: jnm | last post by:
How can I avoid the content of <meta name="Microsoft Border" content="b, default"> is printed, when printing by means of <link rel="stylesheet" href="../print.css" type="text/css"...
1
by: phil2phil | last post by:
Hi, I have an application that loads data into a ListView object, is there anyway for me to loop through that list row by row, column by column. Currently the user selects a name from a dropdown...
1
by: Tark Siala | last post by:
Hi I have ListView contain data, and i want print this listview. i know i can do that by using Datareport and Crystal Report, but i need simple way to print this data. any ony have good idea? ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.