windowsforms-devexpress-dot-xtraprinting-dot-preview-dot-documentviewer.md
Specifies a document supplier for the DocumentViewer.
Namespace : DevExpress.XtraPrinting.Preview
Assembly : DevExpress.XtraPrinting.v25.2.dll
NuGet Package : DevExpress.Win.Printing
[DefaultValue(null)]
public object DocumentSource { get; set; }
<DefaultValue(Nothing)>
Public Property DocumentSource As Object
| Type | Default | Description |
|---|---|---|
| Object | null |
A Object value.
|
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).
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.
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;
Dim report = New XtraReport1()
' Specify thje 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.
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.
reporting-winforms-master-detail-subreport/CS/dxSampleMasterDetailSubreport/Form1.cs#L21
report.CreateDocument();
this.documentViewer1.DocumentSource = report;
}
reporting-winforms-salary-reports/CS/SalaryReports/UserControls/DocumentViewerUserControl.cs#L32
report = value;
documentViewer1.DocumentSource = report;
if (report != null)
reporting-winforms-create-hierarchical-report-from-flat-table/CS/TreeViewReport/Form1.cs#L7
report = new TreeReport(this);
documentViewer1.DocumentSource = report;
treeList1.KeyFieldName = "Key";
Reporting-How-to-Bind-a-Report-to-a-Transformation-Based-Query/CS/Form1.cs#L49
// Display the report in the Document Viewer.
documentViewer1.DocumentSource = report;
#endregion
reporting-winforms-master-detail-subreport/VB/dxSampleMasterDetailSubreport/Form1.vb#L14
report.CreateDocument()
DocumentViewer1.DocumentSource = report
End Sub
reporting-winforms-salary-reports/VB/SalaryReports/UserControls/DocumentViewerUserControl.vb#L28
report_Renamed = value
documentViewer1.DocumentSource = report_Renamed
If report_Renamed IsNot Nothing Then
reporting-winforms-create-hierarchical-report-from-flat-table/VB/TreeViewReport/Form1.vb#L11
report = New TreeReport(Me)
documentViewer1.DocumentSource = report
treeList1.KeyFieldName = "Key"
Reporting-How-to-Bind-a-Report-to-a-Transformation-Based-Query/VB/Form1.vb#L48
' Display the report in the Document Viewer.
documentViewer1.DocumentSource = report
#End Region
See Also