Wednesday, March 27, 2019

Add DevExpress Report Dynamically

Here is the way by which we can add report dynamically to some other report. There is one report which is already there but in some case where we want to add some other report to the main report dynamically or conditionally, we can do so by below way.

(1) Main Report which is already there with some implementation but can also have any other report added to this report dynamically
mainReport mymainReport = new mainReport();

(2) Declare a subreport which is already there but need to add to above main report
XRSubreport otherReport = new XRSubreport();

(3) subrepor which need to add
subReport subReporDetail = new subReport();
... here we can perform some data manipulation for subReport and finally assign it to subreport
otherReport.ReportSource = subReporDetail;

(4) Declare a DetailReportBand and DetailBand 
DetailReportBand detailReportBand = new DetailReportBand();
DetailBand subDetailBand = new DetailBand();

(5) Assign subdetailband height and add otherReport to it
subDetailBaind.HeightF = 0;
subDetailBaind.Controls.Add(otherReport);

(6) Add subDetailBand to detailReportBand
detailReportBand.Bands.Add(subDetailBand);

(7) Finally add detailReportBand to main report which will add this report dynamically
mymainReport.Bands.Add(detailReportBand);

This way we can add report dynamically. In step - (3), If there are many reports already created and conditionally we have to load any report then in this step we can check and add required report dynamically.


No comments:

Post a Comment