-
Mar 23rd, 2010, 09:47 PM
#1
Thread Starter
Lively Member
Printing help...
Looking for a simple way to print, sorry to be asking here I've been reading lots of stuff and its all very confusing to me
Just looking to get a print preview on a simple text document...
Thanks guys
-
Mar 23rd, 2010, 09:54 PM
#2
Frenzied Member
-
Mar 23rd, 2010, 09:59 PM
#3
Re: Printing help...
If you've been reading about .NET printing then you probably already know what you have to do. The .NET printing system is designed to be extremely flexible, but with flexibility often there comes complexity.
Basically, you need to create a PrintDocument and handle its PrintPage event. In that event handler you need to print a page using GDI+, i.e. e.Graphics.DrawString. If there's more than one page then you set e.HasMorePages to True to raise the PrintPage event again. To get a preview you must add a PrintPreviewDialog and associate it with your PrintDocument.
-
Mar 23rd, 2010, 10:15 PM
#4
Thread Starter
Lively Member
Re: Printing help...
Yeah, but all that went over my head to be honest... too much for me...
Crystal reports be the easiest way?
-
Mar 23rd, 2010, 10:18 PM
#5
Addicted Member
Re: Printing help...
Crystal reports is for, as the name suggests, reports. If your text file has nothing to do with database reporting, then I really suggest you take your time to re-read jmc's post His post is probably the simplest explanation I've seen for the .NET printing system.
Anyone who has never made a mistake has never tried anything new. - Einstein
Peace!
-
Mar 23rd, 2010, 10:27 PM
#6
Thread Starter
Lively Member
Re: Printing help...
Fantastic, thanks all!
-
Mar 24th, 2010, 12:00 AM
#7
Fanatic Member
Re: Printing help...
Code:
Imports System.Drawing.Printing.PrintDocument
Public Class Form1
Private _titleFont As Font
Private _detailFont As Font
Private Sub RestaurantDocument_BeginPrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs) Handles Me.BeginPrint
'Create the font objects we are going to print with
_titleFont = New Font(FontFamily.GenericSerif, 16, FontStyle.Bold, GraphicsUnit.Point)
_detailFont = New Font(FontFamily.GenericSerif, 9, FontStyle.Regular, GraphicsUnit.Point)
End Sub
End Class
i am getting an error telling :
Event 'BeginPrint' cannot be found
Please help
-
Mar 24th, 2010, 12:04 AM
#8
Re: Printing help...
That's because you're handling Me.BeginPrint instead of RestaurantDocument.BeginPrint. Me is the form, which has no such event.
It's best to always let the IDE create your event handlers for you so that such mistakes are avoided.
-
Mar 24th, 2010, 12:10 AM
#9
Fanatic Member
Re: Printing help...
ok now i did this and again the same error:
Code:
Imports System.Drawing.Printing.PrintDocument
Public Class Form1
Private _titleFont As Font
Private _detailFont As Font
Private Sub Print_BeginPrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs) Handles Print.BeginPrint
'Create the font objects we are going to print with
_titleFont = New Font(FontFamily.GenericSerif, 16, FontStyle.Bold, GraphicsUnit.Point)
_detailFont = New Font(FontFamily.GenericSerif, 9, FontStyle.Regular, GraphicsUnit.Point)
End Sub
End Class
at the top of the IDE,in the general part i selected the formevents and in the declaration part i search for the beginprint event but i did not get it..then how to let the ide create the event handlers
Please help
-
Mar 24th, 2010, 12:12 AM
#10
Re: Printing help...
Originally Posted by HowTo
ok now i did this and again the same error:
Code:
Imports System.Drawing.Printing.PrintDocument
Public Class Form1
Private _titleFont As Font
Private _detailFont As Font
Private Sub Print_BeginPrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs) Handles Print.BeginPrint
'Create the font objects we are going to print with
_titleFont = New Font(FontFamily.GenericSerif, 16, FontStyle.Bold, GraphicsUnit.Point)
_detailFont = New Font(FontFamily.GenericSerif, 9, FontStyle.Regular, GraphicsUnit.Point)
End Sub
End Class
at the top of the IDE,in the general part i selected the formevents and in the declaration part i search for the beginprint event but i did not get it..then how to let the ide create the event handlers
Please help
As I have already said, the form doesn't have a BeginPrint so of course it's not listed under form events. It's an event of the PrintDocument class, so you have to select your PrintDocument in the left-hand drop-down.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|