Results 1 to 2 of 2

Thread: Print Table Data with Lines

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    Fox, OK
    Posts
    381

    Print Table Data with Lines

    I want to print (to the printer) a copy of student grades from my gradebook program. The grades are in a two dimensional array. Printing the array in table format is no problem but I'd like to add lines to the printout so that it looks like a real gradebook. I might also like to change the background color of each odd line printed to make the data easier to read.

    Any suggestions?

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

    Re: Print Table Data with Lines

    Basically all printing is done using GDI+. At the moment you are presumably calling Print on a PrintDocument, handling its PrintPage event and calling e.Graphics.DrawString to print your text. You just keep doing that, but make extra calls on the e.Graphics object to do the rest of the printing. For the grid lines you'll call DrawLine multiple times. For the coloured background you'll call FillRectangle. You'll need to do some calculations to work out exactly where each element needs to be positioned, but you're probably already doing that for the text.

    Just make sure that you draw everything in the correct order. For instance, you will want to draw the background first, so that the grid lines and cell text gets printed on top of it.
    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

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