0pe*_*tor 6 c# crystal-reports
我在表单上获取用户输入并将其绑定到一个参数,然后该参数将绑定到我的报表.我可以使用单个集合来保存所有参数吗?为我想要传递给报告的每个项目创建一个集合和一个参数似乎是多余的.
为了按照我的要求进行这项工作,我必须为我的表单上的每个参数添加一个集合:
// #1 Setup a collections
ParameterValues firstNameCollection = new ParameterValues();
ParameterValues lastNameCollectoin = new ParameterValues();
Run Code Online (Sandbox Code Playgroud)
然后我创建了实际参数:
// #2 Set the parameters
ParameterDiscreteValue firstNameParam = new ParameterDiscreteValue();
ParameterDiscreteValue lastNameParam = new ParameterDiscreteValue();
Run Code Online (Sandbox Code Playgroud)
绑定值:
// #3 Set the values
firstNameParam.Value = "First Name";
lastNameParam.Value = "Last Name";
Run Code Online (Sandbox Code Playgroud)
将参数添加到集合中:
// #4 Add the parameters to the collection
firstNameCollection.Add(firstNameParam);
lastNameCollectoin.Add(lastNameParam);
Run Code Online (Sandbox Code Playgroud)
并将集合应用于表单:
// #5 Apply the collections to the report
MyReport.DataDefinition.ParameterFields["FirstName"].ApplyCurrentValues(firstNameCollection);
MyReport.DataDefinition.ParameterFields["LastName"].ApplyCurrentValues(lastNameCollectoin);
Run Code Online (Sandbox Code Playgroud)
在 C# 中填充 Crystal Report 参数的正确方法。
MyReport.SetParameterValue("NameOfReportParam", Object);
Run Code Online (Sandbox Code Playgroud)
在最初的问题中,我正在创建参数与引用它,如下所示。
| 归档时间: |
|
| 查看次数: |
187 次 |
| 最近记录: |