4

我在 Windows 应用程序中使用 Devexpress XtraReport 进行报告。我在我的 XtraReport1 中设置了一个参数 param1,其类型为字符串,并使用以下代码传递参数。

private void button1_Click(object sender, EventArgs e)        
{
    XtraReport1 report = new XtraReport1();            
    report.Parameters["param1"].Value = "kashif";
    report.Print();
}

当我按下 button1 时,出现以下窗口并询问我 param1 值已经在其中显示了“kashif”,按钮“提交”和“重置”我的问题是:我不希望这个窗口在我按下 button1 时打开我想直接在其中传递“kashif”而不提示我输入 param1 值。 测试图像

4

2 回答 2

12

从他们这里的文档如何:静默传递参数值

Add a parameter to a report, set the parameter's Modifiers property to Public, and disable the parameter's Parameter.Visible property. When there are no visible parameters in a report, their values are passed "silently" (without exposing the Parameters UI to end-users).

private void button1_Click(object sender, EventArgs e) 
{
    // Create a report instance.
    XtraReport1 report = new XtraReport1();

    // Obtain a parameter, and set its value.
    report.parameter1.Value = 30;

    // Hide the Parameters UI from end-users.
    report.parameter1.Visible = false;

    // Show the report's print preview.
    report.ShowPreview();
}
于 2012-10-03T09:11:32.053 回答
0

你可以喜欢这个**(Asp.net Mvc Razor)

Invoice report = new Invoice();

public ActionResult InvoiceViewerPartial() {
using (CrmDbContext db = new CrmDbContext()) {
    report.DataSource = db.InvoiceItem.ToList();
}
    report.Parameters["InvoiceId"].Value = "Inv0003";                
    return PartialView("_InvoiceViewerPartial", report);
}
于 2017-11-25T09:53:37.940 回答