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.
Unfortunately, activation email could not send to your email. Please try again.

Zoom in PrintPreview

Thread ID:

Created:

Updated:

Platform:

Replies:

20642 Oct 21,2004 04:58 PM Oct 22,2004 01:48 AM Windows Forms 2
loading
Tags: GridControl
Madhavi Balusu
Asked On October 21, 2004 04:58 PM

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?

Madhavi Balusu
Replied On October 21, 2004 05:08 PM

I use C# BTW. Thx.

Administrator [Syncfusion]
Replied On October 22, 2004 01:48 AM

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();
}

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;