Link.ShowPreview() Method
Invokes the Print Preview Form which shows the print preview of the document for this link.
Namespace: DevExpress.XtraPrinting
Assembly: DevExpress.XtraPrinting.v24.1.dll
NuGet Packages: DevExpress.Win.Navigation, DevExpress.Win.Printing
Declaration
Remarks
Use the ShowPreview method to invoke the PrintPreviewFormEx form and show the print preview of the document created for this link. Note that if the link’s document hasn’t been created (the Link.CreateDocument method hasn’t been called for it), then calling the ShowPreview will create it first. Consequently, if a document was created prior to calling the ShowPreview method, and nothing was changed that may force its re-creation, the ShowPreview method doesn’t re-create it, so you need to manually call the Link.CreateDocument method, if required.
The image below displays the standard Print Preview form.
Example
The following code demonstrates how to create a PrintableComponentLink, add it to the PrintingSystem.Links collection, adjust its printing settings, and use it to print an existing GridControl. Use the grid’s OptionsPrint property to customize its printing settings.
using DevExpress.XtraPrinting;
using DevExpress.XtraGrid.Views.Grid;
// ...
// Create printing components.
PrintingSystem printingSystem1 = new PrintingSystem();
PrintableComponentLink printableComponentLink1 = new PrintableComponentLink();
// ...
private void Form1_Load(object sender, EventArgs e) {
// Add the link to the printing system's collection of links.
printingSystem1.Links.AddRange(new object[] { printableComponentLink1 });
// Assign a control to be printed by this link.
printableComponentLink1.Component = gridControl1;
// Assign the printing system to the document viewer.
documentViewer1.PrintingSystem = printingSystem1;
}
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the ShowPreview() method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.