windowsforms-devexpress-dot-xtraprinting-dot-printtool-9fb72b3d.md
Runs the Print dialog to select a printer, specify the print options (number of copies, page range, and paper source) and print the document.
Namespace : DevExpress.XtraPrinting
Assembly : DevExpress.XtraPrinting.v25.2.dll
NuGet Package : DevExpress.Win.Printing
public bool? PrintDialog()
Public Function PrintDialog As Boolean?
| Type | Description |
|---|---|
| Nullable<Boolean> |
true if the user clicks OK in the dialog box; false if the user clicks Cancel ; otherwise null ( Nothing in Visual Basic).
|
The following image illustrates the Print dialog that is invoked by this method and replaces the standard PrintDialog.
If a document has not been created prior to calling the PrintDialog method, the PrintDialog internally calls the Link.CreateDocument method.
To obtain the document after it is generated, use the PrintingSystemBase.Document property of the PrintToolBase.PrintingSystem.
Note
Changing page settings in the Print Dialog does not recreate the current document and affects only the printing result.
To make the PrintTool.PrintDialog method invoke the standard system Print dialog, add the following code to the application’s Program.cs unit ( Program.vb in Visual Basic).
This will replace the DefaultPrintDialogRunner, returned by the PrintDialogRunner.Instance property, with a SystemPrintDialogRunner.
using DevExpress.XtraPrinting.Preview;
// ...
static void Main(string[] args) {
PrintDialogRunner.Instance = new SystemPrintDialogRunner();
// ...
}
Imports DevExpress.XtraPrinting.Preview
' ...
Partial Friend Class MyApplication
<Global.System.Diagnostics.DebuggerStepThroughAttribute()> _
Public Sub New()
' ...
PrintDialogRunner.Instance = New SystemPrintDialogRunner()
End Sub
' ...
End Class
The following code snippets (auto-collected from DevExpress Examples) contain references to the PrintDialog() 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.
pt.PrintingSystem.PrintProgress += new PrintProgressEventHandler(PrintingSystem_PrintProgress);
pt.PrintDialog();
}
reporting-winforms-print-reports-in-batch/CS/BatchPrinting/Form1.cs#L28
if(pt1.PrintDialog() == true) {
foreach(XtraReport report in reports) {
AddHandler pt.PrintingSystem.PrintProgress, New PrintProgressEventHandler(AddressOf PrintingSystem_PrintProgress)
pt.PrintDialog()
End Sub
reporting-winforms-print-reports-in-batch/VB/BatchPrinting/Form1.vb#L33
If pt1.PrintDialog() = True Then
For Each report As XtraReport In reports
See Also