Version

UltraPrintPreviewControl Class

Control for displaying a preview of an System.Drawing.Printing.PrintDocument
Syntax
'Declaration
 
Public Class UltraPrintPreviewControl 
   Inherits UltraPrintPreviewControlBase
   Implements Infragistics.Win.AppStyling.ISupportAppStyling, Infragistics.Win.IUltraControl, Infragistics.Win.IUltraControlElement, Infragistics.Win.Touch.ISupportTouchMetrics, Infragistics.Win.UIAutomation.IProvideUIAutomation 
public class UltraPrintPreviewControl : UltraPrintPreviewControlBase, Infragistics.Win.AppStyling.ISupportAppStyling, Infragistics.Win.IUltraControl, Infragistics.Win.IUltraControlElement, Infragistics.Win.Touch.ISupportTouchMetrics, Infragistics.Win.UIAutomation.IProvideUIAutomation  
Remarks

The UltraPrintPreviewControl is a specialized UltraPrintPreviewControlBase that is used to generate and display print preview pages. The control may be used in association with an UltraPrintPreviewThumbnail, which when associated with the UltraPrintPreviewControl via its UltraPrintPreviewThumbnail.PreviewControl, can be used to change which pages are displayed in the preview control.

The Document property is used to specify which System.Drawing.Printing.PrintDocument will provide the preview pages. By default, the preview pages will be generated when the pages are initially requested - usually once the control is rendered although this can be prevented using the AutoGeneratePreview property. While the preview operation is in progress, a status dialog is displayed that indicates the page number being printed and has a cancel button that can be used to cancel the print operation. This dialog can be suppressed using the DisplayPreviewStatus property. Once the print operation is complete, the PreviewGenerated event is invoked.

The UltraPrintPreviewControl also includes the ability to use the mouse to change the zoom, zoom in on a particular area, place a snapshot of a portion of a page to the clipboard, or scroll based on the MouseAction property.

The control also includes support for a view history. The view history are snapshots of the scroll position and zoom settings at various points. These snapshots are automatically taken as the end-user scrolls, changes the zoom, drags the viewbox of the associated UltraPrintPreviewThumbnail control, etc. As the view history changes, the ViewHistoryChanged event is invoked. The HasNextView and HasPreviousView properties can be used to determine whether the end-user can navigate to a previous or next item in the view history. The PerformAction method can be used to navigate back and forward in the view history (using actions of PreviousView and NextView respectively) or clear the view history (using an action of ClearViewHistory).

Example
This sample demonstrates how to configure several properties of the UltraPrintPreviewControl.

Public Sub New()

   InitializeComponent()
   
   ' Give the control a reference to a PrintDocument-derived object.
   Me.ultraPrintPreviewControl1.Document = Me.ultraSchedulePrintDocument1
   
   ' Turn off the AutoGeneratePreview feature.
   ' If you do this you will be responsible for telling the control 
   ' when to start the preview operation using the GeneratePreview method.
   ' Alternatively you can set the DisplayPreviewStatus to false and it will 
   ' run the print operation but not show a status dialog.
   Me.ultraPrintPreviewControl1.AutoGeneratePreview = False
   Me.ultraPrintPreviewControl1.DisplayPreviewStatus = False
   
   ' Only allow for up to three preview pages to be generated.
   Me.ultraPrintPreviewControl1.MaximumPreviewPages = 3
   
   ' If the resolved mouse action is not already DynamicZoom, make it so.
   If Me.ultraPrintPreviewControl1.MouseActionResolved <> Infragistics.Win.Printing.PreviewMouseAction.DynamicZoom Then
      Me.ultraPrintPreviewControl1.MouseAction = Infragistics.Win.Printing.PreviewMouseAction.DynamicZoom
   End If 

   ' Use anti-aliasing to ensure that the image is smooth and clear.
   Me.ultraPrintPreviewControl1.UseAntiAlias = True

End Sub
public Form1()
{
	InitializeComponent();

	// Give the control a reference to a PrintDocument-derived object.
	this.ultraPrintPreviewControl1.Document = this.ultraSchedulePrintDocument1;

	// Turn off the AutoGeneratePreview feature.
	// If you do this you will be responsible for telling the control 
	// when to start the preview operation using the GeneratePreview method.
	// Alternatively you can set the DisplayPreviewStatus to false and it will 
	// run the print operation but not show a status dialog.
	this.ultraPrintPreviewControl1.AutoGeneratePreview = false;
	this.ultraPrintPreviewControl1.DisplayPreviewStatus = false;

	// Only allow for up to three preview pages to be generated.
	this.ultraPrintPreviewControl1.MaximumPreviewPages = 3;

	// If the resolved mouse action is not already DynamicZoom, make it so.
	if( this.ultraPrintPreviewControl1.MouseActionResolved != Infragistics.Win.Printing.PreviewMouseAction.DynamicZoom )
		this.ultraPrintPreviewControl1.MouseAction = Infragistics.Win.Printing.PreviewMouseAction.DynamicZoom;

	// Use anti-aliasing to ensure that the image is smooth and clear.
	this.ultraPrintPreviewControl1.UseAntiAlias = true;
}
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also