Results 1 to 5 of 5

Thread: printing [solved]

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    printing [solved]

    I'm never good in the printing/graphics area so I hope you can help me.
    I can make text print, thats cool but what I am not good at is how to make it print the contents of the form (for each control in form...print text) to the page. Now, what I need for it is to align them and make them print in order, example going from top left to bottom right...line by line...

    so it wouldnt matter where I place the controls on the form, I just want their textual value to be printed next to the previous textual value, and if the line is almost at the edge of the paper, to move to the next line and continue printing.

    how can this be done?
    Last edited by Techno; Oct 10th, 2006 at 06:48 PM.

    MVP 2007-2010 any chance of a regain?
    Professional Software Developer and Infrastructure Engineer.

  2. #2
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: printing

    Code:
    foreach(Control cc in this.Controls)
    myText+=cc.Text + "\r\n";

    ?
    I don't live here any more.

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: printing

    nope. lol
    I want to print the contents (text) of the current control (cc in your example) to the document in a way that it will keep printing line by line, but it will move to the NEXT line once it reaches the end of that line

    MVP 2007-2010 any chance of a regain?
    Professional Software Developer and Infrastructure Engineer.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: printing

    You need to measure the text you're about to print using the MeasureString method and compare that to the amount of available width left on the page. You know that width because you know where the right edge of the last string you drew is. If there is not enough room left on the current line you set the X coordinate back to zero and increase the Y coordinate so that the text gets drawn to the far left and below the previous. This appears to be the next line to the reader, but of course we know that there are no actual lines in .NET printing. Just the coordinates that you specify.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: printing

    yes I found that out after a few minutes of my last post, thanks very much! good to know that I'm doing it correctly

    MVP 2007-2010 any chance of a regain?
    Professional Software Developer and Infrastructure Engineer.

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