Grid printing

Hi

I have several grids of different sizes to print (one at a time) in my program - I have been using the print preview component, but this now looks so old it is embarrising to show to clients. I have a preview system that works fine for charts, richedits and other graphic I use, because either I know how big the objects are and can therefore fit them on the preview page, or for the case richedit they have pagecount and metafiles exposed to me.

I am struggling to get sarted with this for Advstringgrids - what I hoped was that I could pass the printpreview canvas (ideally mettafile) from your component back to mine in some way, but it does not appear to be available to me, nor do the funtions splitting the grid up etc - do you have any thoughts on how I can get this going? If I start from scrach I will have to code all the formatting etc that the advstringgrid can hold.

Your, hoping you have a good idea!

Richard

Did you look at grid.PrintDrawRect() ? With this function you can draw a selected range of cells to a canvas. So, you could create a memory bitmap canvas and draw on this canvas and then show it on screen (possibly with stretching to fit where it needs to be displayed)

Hi Bruno

Yes I had a look at that, but could work out how to get at the different pages/ For example, many of me grids are 3 or 3 pages wide by 4-5 pages long when printed. Your previewer works nicely in splitting them up to print sensibly, but I couldn't figure out how to access each page separately so I could draw it to my preview component. - Is that code exposed to me?

Thanks

Richard

This is not exposed with grid.PrintDrawRect. Your could would need to determine yourself how much data (cells) to fit on a page and pass the appropriate nr. of cells via the grid.PrintDrawRect params.

Thanks - I feared that was the case - I was just hoping that I could tag onto you fine logic rather than create my own - Oh well!

thank for your time

Richard