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 03:19 PM

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 06:05 AM

Thanks a lot, that worked great!


DO Doug December 19, 2003 06:51 AM

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 09:29 AM

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)
{
	base.OnPrintPage(ev);
	if(!ev.HasMorePages)
	{
		//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);
		//botGridRect.Inflate(1,1);
		ev.Graphics.DrawRectangle(Pens.Black, botGridRect);
	}
}


DO Doug December 19, 2003 10:50 AM

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 11:40 AM

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.

Loader.
Live Chat Icon For mobile
Up arrow icon