Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old February 26th, 2006, 04:40 AM
Registered User
Join Date: Feb 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Phoenix Blade
Default Help with printing code


I bought the book "Beginning Visual C# 2005", and have gotten up to the "Simple Text Editer" under Using Common Dialogs. I have made it fully and it works perfectly except when I try to print a very long line of text it prints the first part then cuts off the rest of the line at the page boundry.

private void OnPrintPage(object sender, PrintPageEventArgs e)
            int x = e.MarginBounds.Left;
            int y = e.MarginBounds.Top;
            while (linesPrinted < lines.Length)
                e.Graphics.DrawString(lines[linesPrinted++], textBoxEdit.Font,
                    Brushes.Black, x, y);
                y += textBoxEdit.Font.Height;
                if (y >= e.MarginBounds.Bottom)
                    e.HasMorePages = true;
            linesPrinted = 0;
            e.HasMorePages = false;
private void OnBeginPrint(object sender, PrintEventArgs e)
            char[] param = { '\n' };
            if (dlgPrint.PrinterSettings.PrintRange == PrintRange.Selection)
                lines = textBoxEdit.SelectedText.Split(param);
                lines = textBoxEdit.Text.Split(param);

            int i = 0;
            char[] trimParam = { '\r' };
            foreach (string s in lines)
                lines[i++] = s.TrimEnd(trimParam);
private void OnEndPrint(object sender, PrintEventArgs e)
            lines = null;
I have no idea how to stop this from happening, could you please help me.

Whether you think you can or think you can't, you're probably right.

Similar Threads
Thread Thread Starter Forum Replies Last Post
C# Printing janvov C# 2 January 17th, 2007 01:25 PM
Problem printing bar code! cyberrider VB How-To 1 November 5th, 2005 04:32 PM
Printing a code module Clive Astley Beginning VB 6 2 July 7th, 2005 12:15 AM
Printing Errors / Example Code Fire BOOK: Access 2003 VBA Programmer's Reference 0 April 12th, 2005 02:52 PM
capturing printing settings when printing reports nikolaosk Access VBA 0 February 8th, 2005 04:14 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.