DataSourceManager Class
Allows you to get data source(s) from a report or controls.
Namespace: DevExpress.XtraReports
Assembly: DevExpress.XtraReports.v20.2.dll
NuGet Packages: DevExpress.Reporting.Core, DevExpress.WindowsDesktop.Reporting.Core
Declaration
Remarks
Use the static methods declared in this class to get data sources from a report and its controls/parameters, replace a data source, or add data sources to a report.
Operation | Methods |
---|---|
Get data sources | The GetDataSources overloaded methods |
Get controls and parameters that have data sources | The GetDataSourceAssignables overloaded methods |
Get text bricks that contain the specified text | The GetBricksByText overloaded methods |
Get controls and parameters that have the specified data source | The GetDataSourceAssignablesByDataSource(XtraReport, Object, Boolean) method |
Add data sources to a report | The AddDataSources(XtraReport, IComponent[]) method |
Example
The following code retrieves all data sources in a report and its controls, and populates these data sources with data:
using DevExpress.XtraReports.UI;
using DevExpress.DataAccess.Json;
using DevExpress.XtraReports;
// ...
// Create a report and assign a JSON data source to it.
XtraReport report = new XtraReport();
var jsonDataSource1 = new JsonDataSource();
report.DataSource = jsonDataSource1;
// Add the report's BeforePrint event handler
report.BeforePrint += PopulateDataSources;
// Create a chart and place it in the report's footer band.
DetailBand detailBand = new DetailBand();
ReportFooterBand reportFooterBand = new ReportFooterBand();
report.Bands.AddRange(new Band[] { detailBand, reportFooterBand });
XRChart chart = new XRChart();
var jsonDataSource2 = new JsonDataSource();
chart.DataSource = jsonDataSource2;
reportFooterBand.Controls.Add( chart );
// ...
// Retrieve all data sources from the report and its controls.
private void PopulateDataSources(object sender, System.Drawing.Printing.PrintEventArgs e) {
var report = sender as XtraReport;
var dataSources = DataSourceManager.GetDataSources(report, true);
foreach (var dataSource in dataSources) {
(dataSource as JsonDataSource).Fill();
}
}
Inheritance
Object
DataSourceManager
See Also