We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Print multiple grid controls on one page

Is it possible to print multiple grid controls on a single page with a single click, one right after the other? I saw an example to print 2 grids to 2 different printouts, but I need them on the same printout. Thanks in advance for any help you can give me.

6 Replies

AD Administrator Syncfusion Team December 18, 2003 08:19 PM UTC

This can be acheived by deriving the GridPrintDocument and overriding OnPrintPage Method. Here you can customize it according to your needs. Here is a sample.

DO Doug December 19, 2003 11:05 AM UTC

Thanks a lot, that worked great!

DO Doug December 19, 2003 11:51 AM UTC

After working with the printout a little more, I noticed that if i try to print a grid that is longer than a single page, it will only print the first page. Is there an easy way to get around this problem? Thanks for all your help.

AD Administrator Syncfusion Team December 19, 2003 02:29 PM UTC

You can try using the baseclass to print the first grid, and then only print the second if there are no more pages of the first grid to print.
protected override void OnPrintPage(PrintPageEventArgs ev)
		//set where you want the second grid displayed...
		int width = grid2.Model.ColWidths.GetTotal(0, grid2.Model.ColCount);
		int height = grid2.Model.RowHeights.GetTotal(0, grid2.Model.RowCount);
		Rectangle botGridRect = new Rectangle(ev.MarginBounds.Left, ev.PageBounds.Height/2, width, height);
		grid2.DrawGrid(ev.Graphics, botGridRect, false);
		ev.Graphics.DrawRectangle(Pens.Black, botGridRect);

DO Doug December 19, 2003 03:50 PM UTC

Does this mean it is not possible if both grids happen to be bigger than 1 page long? Thanks again.

AD Administrator Syncfusion Team December 20, 2003 04:40 PM UTC

The sample was really intended to print grids that you know would fit on a single page. Currently, I do not know of a good way to continuously print several grids over several pages unless you allow each grid to start on its on page. We do intend to upgrade the printing support after we get the 2.0 version released, but I do not know a time frame for this additional support.

Live Chat Icon For mobile
Up arrow icon