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
close icon

Zoom in PrintPreview

Hi, I would like to set the size of the preview dilaog (PrintPreviewDialog) to the size of the application''s main window and zoom it to 100%. How do I do that?

2 Replies

MB Madhavi Balusu October 21, 2004 09:08 PM UTC

I use C# BTW. Thx.


AD Administrator Syncfusion Team October 22, 2004 05:48 AM UTC

The PrintPreviewDialog is a .Net Framework form, so you would use the same techniques to size and position it as you would with any form. To set the zoom factor, this is also a .Net Framework process. You somehow have to get the PrintPreviewControl that is embedded in the PrintPreviewDialog and set some properties on that object. Below is code that worked for me. There may be better ways of doing this.
private void button1_Click(object sender, System.EventArgs e)
{
	GridDataBoundGrid grid = this.gridDataBoundGrid1;
	GridPrintDocument pd = new GridPrintDocument(grid, true);  
	PrintPreviewDialog dlg = new PrintPreviewDialog();
	dlg.Document = pd;
	dlg.Bounds = new Rectangle(0, 0, grid.Width, grid.Height);
	Point gridLoc = grid.Location;
	Point pt = this.gridDataBoundGrid1.PointToScreen(gridLoc);
	dlg.SetDesktopLocation(pt.X - gridLoc.X, pt.Y - gridLoc.Y);
	dlg.StartPosition = FormStartPosition.Manual;
	PrintPreviewControl ppc = null;
	foreach(Control c in dlg.Controls)
	{
		if(c is PrintPreviewControl)
		{
			ppc = c as PrintPreviewControl;
			ppc.AutoZoom = true;
			ppc.Zoom = 1;
			break;
		}
	}
	dlg.ShowDialog();
}

Loader.
Live Chat Icon For mobile
Up arrow icon