XtraReport1添加参数

Posted bwdblogs

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了XtraReport1添加参数相关的知识,希望对你有一定的参考价值。

using System;
using System.Windows.Forms;
using DevExpress.XtraReports.UI;
using DevExpress.XtraReports.Parameters;
// ...

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();
}

以上是关于XtraReport1添加参数的主要内容,如果未能解决你的问题,请参考以下文章

怎么给http post添加参数

如何为函数参数“*argv”添加解析器参数

scrapy 怎样添加命令行参数

使用NGUI添加Label后不能修改参数,请问该如何解决

安装centos7添加acpi=off参数

在jsp文件中添加参数