|
-
May 9th, 2010, 02:49 PM
#1
Thread Starter
Hyperactive Member
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?
-
May 9th, 2010, 06:22 PM
#2
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|