Results 1 to 10 of 10

Thread: Printing help...

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2010
    Location
    Ireland
    Posts
    85

    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

  2. #2
    Frenzied Member
    Join Date
    Jul 2009
    Posts
    1,103

    Re: Printing help...

    you may use the crystal reports to print

    If you find my reply helpful , then rate it

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,296

    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.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Mar 2010
    Location
    Ireland
    Posts
    85

    Re: Printing help...

    Yeah, but all that went over my head to be honest... too much for me...

    Crystal reports be the easiest way?

  5. #5
    Addicted Member garyjohn_2000's Avatar
    Join Date
    Apr 2005
    Location
    Timbaland
    Posts
    243

    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!

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Mar 2010
    Location
    Ireland
    Posts
    85

    Re: Printing help...

    Fantastic, thanks all!

  7. #7
    Fanatic Member
    Join Date
    Dec 2009
    Posts
    904

    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

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,296

    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.

  9. #9
    Fanatic Member
    Join Date
    Dec 2009
    Posts
    904

    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

  10. #10
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,296

    Re: Printing help...

    Quote Originally Posted by HowTo View Post
    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
  •  



Click Here to Expand Forum to Full Width