I have a grid that I would like to be able to print and also print preview. The grid may has many bands and expandable regions - these are not displayed properly when using the ultraPrintPreviewDialog control.
The call to wingrid.Print(displayLayout,printDoc) prints how I want it to (i.e. all rows including those not visible in collapsed regions) and also wingrid.PrintPreview(displayLayout,printDoc).
The problem with using PrintPreview() on the grid is that the viewer has a lot less functionality (and a win 95 look).
Is there a way to the displaylayout of the grid with the UltraPrintPreviewDialog so that it behaves in the same way as wingrid.Print() and wingrid.PrintPreview()?
Hi Crystal,
Handle the InitializeRow event of the grid. Inside this event, you can examine e.Row.Band.Layout.IsPrintLayout and this will tell you if the row is an on-screen row or a print row. Either way, you can simply set the Expanded property on the row. Setting the Expanded property on a print row will not affect the on-screen row and vice versa.
Hi Mike, we had similar requirement that some row will be collapsed in grid printing. Could you explain in more details how exactly we can set the rows collapsed in InitializePrint event handler? Sample code is much appreciated.
Crystal.
Handle the InitializePrint event of the grid and you can modify the e.PrintLayout there to show or hide anything you like.
I am using the UltraPrintPreviewDialog - that's the problem. The print preview shows the grid as it appears on-screen, whereas the print preview on the grid shows all of the grid's columns and rows (I have groupings so some data is hidden in collapsed regions) - which is what I'm after. I presume this is because I cannot pass the displaylayout to the UltraPrintPreviewDialog (?). What I would like to know is if I can get the UltraPrintPreviewDialog to produce and print a preview with all of my grid's data, the same way that UltraGrid.PrintPreview() does.
Hi,
The PrintPreview method on the grid uses the MS PrintPreviewDialog control. If you want a more modern print preview look, I recommend you check out the UltraGridPrintDocument and the UltraPrintPreviewDialog components.