DocumentViewer.DocumentSource Property
Specifies a document supplier for the DocumentViewer.
Namespace: DevExpress.XtraPrinting.Preview
Assembly: DevExpress.XtraPrinting.v24.1.dll
NuGet Packages: DevExpress.Win.Navigation, DevExpress.Win.Printing
Declaration
Property Value
Type | Default | Description |
---|---|---|
Object | null | A Object value. |
Remarks
Use the DocumentSource
property to assign an object that will supply a document for the DocumentViewer. This object must implement the IDocumentSource interface (typically, this is an XtraReport, PrintingSystem or RemoteDocumentSource object).
Design Time
You can specify this property at design time using the control’s smart tag.
Note
Rebuild the project so that the newly added reports appear in the Document Source drop-down menu.
NET Core projects do not display reports in this list. You should assign the DocumentSource
property in code.
Runtime
var report = new XtraReport1();
// Specify the print preview settings if needed.
report.ShowPreviewMarginLines = false;
// The CreateDocument call is unnecessary
// unless you disable the RequestDocumentCreation option.
// report.CreateDocument();
documentViewer1.DocumentSource = report;
If the RequestDocumentCreation is enabled (default), the document for preview is generated automatically. Otherwise, when the DocumentSource
property is assigned at runtime, you should explicitly call the CreateDocument
method of a specified document supplier object to generate a document ready to preview.
You can also enable the UseAsyncDocumentCreation option to specify whether the DocumentViewer should create a report document asynchronously in a separate task.
For more information, refer to the following tutorials.
- How to: Preview, Export and Print an XtraReport
- How to: Preview, Export and Print a Windows Forms Control
- How to: Preview, Export and Print a Remotely Created Document
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the DocumentSource property.
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.