views:

198

answers:

2

Boy did I get an education looking into this. I guess I've been spoiled by Powerbuilder, which has fantastic functionality for this out of the box.

Does anyone seriously write custom documentpaginator objects to handle reporting needs for their LOB apps? I want to be able to print "for free" and not have to code like crazy just to take whats on the screen and throw it on paper.

How are people doing this? Does anyone have a recommended 3rd party for allowing printing of largish datagrids?

Thanks

+1  A: 

Paginating datagrids is a huge, huge pain. Simply drawing the grid on a page will not work as you have to handle things like fixed layout, expanding cells horizontally and vertically to show all data, word wrapping, splitting columns and rows into the page margin, splitting cells that overflow a page into multiple pages. Remember you can't scroll or resize a control on a piece of paper. Even if you find a magic control that can do all that, a grid with borders, shadows, and backgrounds that look good on a screen won't look good on paper.

For an old WinForms app that printed datagrids we implemented a completely separate report API for printouts. We printed the underlying ADO.Net dataSource using the free ReportViewer control. A tutorial is at gotreportviewer.com.

Dour High Arch
thanks for that. Ideally I'd like to identify a gridstyle control out there that has a print method right on it. We're using LINQ to SQL for this project so far.
FauxReal
@FauxReal: If you can find a control that can do that, let me know. I added more detail to my answer as to why I believe you won't find one.
Dour High Arch
well Xceed's grid control will print grids like crazy. Does a great job of it too. Won't serve every imaginable report need, but does printing grids great.
FauxReal
A: 

I've found the easiest way is to implement a generalized DocumentPaginator class for paginating anything I can put on screen. With my DocumentPaginator I don't need to worry about printing because I can take any arbitrary WPF control and tell it to print, and it will take multiple pages if necessary to display all the data.

I also use an inherited attached bool property "PrintView" that the user can control. Some of my controls change their appearance somewhat using a trigger on the "PrintView" property, so they will look better when printed.

I describe my DocumentPaginator solution in more detail in this answer, including a description of the algorithm required.

Ray Burns