如何将参数传递给reportdocument并直接打印 这是我的代码:
ReportDocument rd = new ReportDocument();
ParameterField p=new ParameterField();
p.Name="parm1";
ParameterDiscreteValue pv = new ParameterDiscreteValue();
pv.Value = "value1";
p.CurrentValues.Add(pv);
string str = Path.Combine(Application.StartupPath, "Print\\rpt1.rpt");
//rd.SetParameterValue("parm1", "test");
rd.Load(str);
rd.ParameterFields.Add(p);
var dialog = new PrintDialog();
rd.PrintOptions.PrinterName = dialog.PrinterSettings.PrinterName;
rd.PrintToPrinter(1, false, 0, 0);
答案 0 :(得分:0)
我现在还没有。但是在添加这样的参数之前我更改了rd.Load(str);
:
ReportDocument rd = new ReportDocument();
rd.Load(str);
ParameterField p=new ParameterField();
p.Name="parm1";
ParameterDiscreteValue pv = new ParameterDiscreteValue();
pv.Value = "value1";
p.CurrentValues.Add(pv);
string str = Path.Combine(Application.StartupPath, "Print\\rpt1.rpt");
//rd.SetParameterValue("parm1", "test");
rd.ParameterFields.Add(p);
var dialog = new PrintDialog();
rd.PrintOptions.PrinterName = dialog.PrinterSettings.PrinterName;
rd.PrintToPrinter(1, false, 0, 0);
it works correctly.