Back to Devexpress

DocumentViewer.DocumentSource Property

windowsforms-devexpress-dot-xtraprinting-dot-preview-dot-documentviewer.md

latest7.7 KB
Original Source

DocumentViewer.DocumentSource Property

Specifies a document supplier for the DocumentViewer.

Namespace : DevExpress.XtraPrinting.Preview

Assembly : DevExpress.XtraPrinting.v25.2.dll

NuGet Package : DevExpress.Win.Printing

Declaration

csharp
[DefaultValue(null)]
public object DocumentSource { get; set; }
vb
<DefaultValue(Nothing)>
Public Property DocumentSource As Object

Property Value

TypeDefaultDescription
Objectnull

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

csharp
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;
vb
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

csharp
report.CreateDocument();
    this.documentViewer1.DocumentSource = report;
}

reporting-winforms-salary-reports/CS/SalaryReports/UserControls/DocumentViewerUserControl.cs#L32

csharp
report = value;
documentViewer1.DocumentSource = report;
if (report != null)

reporting-winforms-create-hierarchical-report-from-flat-table/CS/TreeViewReport/Form1.cs#L7

csharp
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

csharp
// Display the report in the Document Viewer.
documentViewer1.DocumentSource = report;
#endregion

reporting-winforms-master-detail-subreport/VB/dxSampleMasterDetailSubreport/Form1.vb#L14

vb
report.CreateDocument()
    DocumentViewer1.DocumentSource = report
End Sub

reporting-winforms-salary-reports/VB/SalaryReports/UserControls/DocumentViewerUserControl.vb#L28

vb
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

vb
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

vb
' Display the report in the Document Viewer.
documentViewer1.DocumentSource = report
#End Region

See Also

DocumentViewer Class

DocumentViewer Members

DevExpress.XtraPrinting.Preview Namespace