Back to Devexpress

DataSourceManager.GetDataSourceAssignables(XtraReport, Boolean) Method

xtrareports-devexpress-dot-xtrareports-dot-datasourcemanager-dot-getdatasourceassignables-x28-devexpress-dot-xtrareports-dot-ui-dot-xtrareport-system-dot-boolean-x29.md

latest3.4 KB
Original Source

DataSourceManager.GetDataSourceAssignables(XtraReport, Boolean) Method

Returns a report and its elements (subreports, controls, bands, parameters) to which a data source can be assigned.

Namespace : DevExpress.XtraReports

Assembly : DevExpress.XtraReports.v25.2.dll

NuGet Package : DevExpress.Reporting.Core

Declaration

csharp
public static IEnumerable<IDataSourceAssignable> GetDataSourceAssignables(
    XtraReport report,
    bool includeSubReports = false
)
vb
Public Shared Function GetDataSourceAssignables(
    report As XtraReport,
    includeSubReports As Boolean = False
) As IEnumerable(Of IDataSourceAssignable)

Parameters

NameTypeDescription
reportXtraReport

A report instance.

|

Optional Parameters

NameTypeDefaultDescription
includeSubReportsBooleanFalse

true to include elements from subreports; otherwise, false.

|

Returns

TypeDescription
IEnumerable<IDataSourceAssignable>

A collection that includes the report and its elements.

|

Example

The following code sample shows how to do the following:

  1. Retrieve a report and its elements (subreports, controls, bands, parameters) to which a data source can be assigned.
  2. Replace a data source for each report chart (element of the XRChart type) with a new JSON data source.
csharp
using DevExpress.DataAccess.Json;
using DevExpress.XtraReports.UI;
using DevExpress.XtraReports;
//...

var report = new XtraReport1();

var dataSourceAssignables = DataSourceManager.GetDataSourceAssignables(
    report,
    includeSubReports: true
);

var jsonDataSource = new JsonDataSource() { /* ... */ };

foreach (var elem in dataSourceAssignables) {
    if (elem is XRChart) {
        DataSourceManager.ReplaceDataSource(report, elem.DataSource, jsonDataSource);
    }
}
vb
Imports DevExpress.DataAccess.Json
Imports DevExpress.XtraReports.UI
Imports DevExpress.XtraReports
'...

Private report = New XtraReport1()

Private dataSourceAssignables = DataSourceManager.GetDataSourceAssignables(report, includeSubReports:= True)

Private jsonDataSource = New JsonDataSource()

For Each elem In dataSourceAssignables
    If TypeOf elem Is XRChart Then
        DataSourceManager.ReplaceDataSource(report, elem.DataSource, jsonDataSource)
    End If
Next elem

See Also

DataSourceManager Class

DataSourceManager Members

DevExpress.XtraReports Namespace