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 :blush:
Just looking to get a print preview on a simple text document...
Thanks guys :duck:
Printable View
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 :blush:
Just looking to get a print preview on a simple text document...
Thanks guys :duck:
you may use the crystal reports to print :)
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.
Yeah, but all that went over my head to be honest... too much for me...
Crystal reports be the easiest way?
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.
Fantastic, thanks all! :)
i am getting an error telling :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
Event 'BeginPrint' cannot be found
Please 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.
ok now i did this and again the same error:
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:confused: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
Please help