I keep telling everyone WinForms printing gets easier in Whidbey, but that doesn't help them today...

There really is no such thing as easily printing a window.  You see windows are highly oriented to the display, they have virtual regions that are only visible when scrolled, and often they are much wider than they are tall, so you get some issues with even fitting on the paper if you print the form as is straight from the screen.  That doesn't stop people from wanting the feature.  In fact, most people think it should be an easy requirement and simply demand it.  One of my friends found printing the contents of his form as an extra  question in one of his introduction to computer programming classes.  Of course he found out rather quickly how difficult it was.  You can read about that here Printing a ListBox in VB.  Of course I gave him some suggestions, but I couldn't really answer or solve his question.  That definitely disappoints me.

Why was printing left where it was?  Well, because it is hard to print.  What does a list box of three visible elements, but 20 actual elements display as in a report or printed version of the form?  How about a huge data-grid with 1000 elements, but only 10 visible?  What happens when there are nested relationships?  The answers to these are highly application dependent.  The next version of Windows Forms (Whidbey) does have some answers though.

With Whidbey there is the concept of a Renderer.  You get new classes like CheckBoxRenderer that allow you to specify the Graphics to render into.  You might say these existed already in ControlPaint, and you would be right.  The renderer classes even use ControlPaint still, but they have an extra set of code that will use a VisualStyleRenderer instead.  Will this help any in printing?  Maybe and maybe not.  It will let you get closer to the WYSIWYG approach if you want to render a form as it appears on the screen on a piece of paper.  However, they are still lacking renderers for common controls like the ListBox that people like John are having such a hard time with.

Maybe I'm wrong then.  Maybe Whidbey really doesn't help you with printing.  They certainly don't have any print adapters that adapt a visual control to a printed version of the control.  That would be pretty sweet if you ask me.  They also require you to pass in loads of arguments to the renderer.  Things like check state and rectangles for sizing that could easily be pulled off of a control instead (aka, render THIS control dummy, don't make me specify a bunch of arguments).  Maybe it is time to make a larger investment in Crystal Reports?

Published Monday, May 03, 2004 12:22 PM by Justin Rogers
Filed under: ,

Comments

Tuesday, May 04, 2004 11:19 AM by Ron

# re: I keep telling everyone WinForms printing gets easier in Whidbey, but that doesn't help them today...

>Maybe it is time to make a larger investment in Crystal Reports?

Or maybe you could check out Active Reports. http://www.datadynamics.com/

Leave a Comment

(required) 
(required) 
(optional)
(required)