Dynamically set devexpress report parameter

后端 未结 1 1429
旧时难觅i
旧时难觅i 2021-01-17 05:52

I am new to devexpress reports. I know how to set the data for my report e.g. I got the following codes. I can populate and generate my report. The issue in the parameter de

相关标签:
1条回答
  • 2021-01-17 06:05

    I suggest you go through these example and documentation references.

    How to: Create a Report with Parameters (Runtime Sample)
    How to add parameters to a report at runtime
    Passing a parameter to the report at runtime
    how to pass parameter in devexpress report

    example:

    private void simpleButton1_Click(object sender, EventArgs e) {
        // Create a report instance.
        XtraReport1 report = new XtraReport1();
    
        // Create a parameter and specify its name.
        Parameter param1 = new Parameter();
        param1.Name = "CatID";
    
        // Specify other parameter properties.
        param1.Type = typeof(System.Int32);
        param1.Value = 1;
        param1.Description = "Category: ";
        param1.Visible = true;
    
        // Add the parameter to the report.
        report.Parameters.Add(param1);
    
        // Specify the report's filter string.
        report.FilterString = "[CategoryID] = [Parameters.CatID]";
    
        // Force the report creation without previously 
        // requesting the parameter value from end-users.
        report.RequestParameters = false;
    
        // Show the parameter's value on a Report Header band.
        XRLabel label = new XRLabel();
        label.DataBindings.Add(new XRBinding(param1, "Text", "Category: {0}"));
        ReportHeaderBand reportHeader = new ReportHeaderBand();
        reportHeader.Controls.Add(label);
        report.Bands.Add(reportHeader);
    
        // Assign the report to a ReportPrintTool,
        // to hide the Parameters panel,
        // and show the report's print preview.
        ReportPrintTool pt = new ReportPrintTool(report);
        pt.AutoShowParametersPanel = true;
        pt.ShowPreviewDialog();
    }
    

    Hope this help.

    0 讨论(0)
提交回复
热议问题