Ticket Q39657
Visible to All Users

XAFWIN: using subreport in XAF application

created 16 years ago

Hi there
Could you please help me to make this code work?
I'm trying to make use of sub report and filter it in the below code as it printing
using System.Collections;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using DevExpress.Persistent.Base;
using DevExpress.ExpressApp.Reports.Win;
using DevExpress.ExpressApp.Reports;
using DevExpress.ExpressApp.Filtering;
using DevExpress.Data.Filtering;
using DevExpress.XtraReports.UI;
using System.Drawing;
using AAAA.Module.Custom;
using AAAA.Module.Data;
private void OnBeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) {
        XRSubreport subreport = sender as XRSubreport;
        TestLine line = subreport.Report.GetCurrentRow() as TestLine ;
        ReportData reportdata = line.Session.FindObject<CustomReportData>(new BinaryOperator("Name", "SYS0001"));
        XafReport report = reportdata.LoadXtraReport(Application.CreateObjectSpace()); ///We don't have Application.CreateObjectSpace());
        report.SetFilteringObject(new LocalizedCriteriaWrapper(report.DataType, new OperandProperty("Oid") == line.Oid));
                subreport.ReportSource = report;

}
to add sub report we do following
   public class CustomReportData : ReportData
    {
        public CustomReportData(Session session) : base(session) { }
        protected override XafReport CreateReport()
        {
            XafReport report = base.CreateReport();
            report.DesignerLoaded += new DevExpress.XtraReports.UserDesigner.DesignerLoadedEventHandler(report_DesignerLoaded);
            return report;
        }
        void report_DesignerLoaded(object sender, DevExpress.XtraReports.UserDesigner.DesignerLoadedEventArgs e)
        {
            IToolboxService ts = (IToolboxService)e.DesignerHost.GetService(typeof(IToolboxService));
            ts.AddToolboxItem(new ToolboxItem(typeof(XRBarCustomGraph)));
            ts.AddToolboxItem(new ToolboxItem(typeof(XRSubreport)));
        }
    }
Best regards,
Duc Hong Doan

Show previous comments (3)

    thank you so much for the hint.
    Appreciate your help!

      What about publishing your questions in the Support Center?
      Sure. Please go ahead.

      Dennis Garavsky (DevExpress) 16 years ago

        Thanks, Duc!

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.