Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am trying to print records in listview using the printdialog control, print document control and a button. The problem is nothing gets printed even though there are records in the listview.

the code is:
VB
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
   PrintDialog1.Document = PrintDocument1
   PrintDialog1.PrinterSettings = PrintDocument1.PrinterSettings
   PrintDialog1.AllowSomePages = True
   If PrintDialog1.ShowDialog = DialogResult.OK Then
      PrintDocument1.PrinterSettings = PrintDialog1.PrinterSettings
      PrintDocument1.Print()
   End If
End Sub
Posted
Comments
Dave Kreskowiak 14-Feb-15 16:47pm    
The code you posted just starts the print operation. You have to show the code that actually does the page image generation. Where's the PrintDocument.PrintPage event code?
hlsc1983 14-Feb-15 16:54pm    
sorry, i dont have any such code. can you please guide me further?
Dave Kreskowiak 14-Feb-15 17:30pm    
Well that would be why you're not getting anything on the printer. Just telling the dialog box which printer to print to does NOT automatically print anything for you. YOU have to supply the code to generate the image that goes on the page!!

There are a ton of How-To's on the web on this. All you have to do is Google for "C# print to printer".

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900