Crystal Report Parameter Programming Sample Code

zhaozj2021-02-16  56

Imports Crystaldecisions.Shared Imports Crystaldecisions.crystalReports.Engine

Private const rpt_name as string = "customerorders.rpt" private const parameter_field_name as string = "CustomerID"

PRIVATE SUB Page_Load (Byval E AS System.EventArgs) Handles mybase.load 'Place the initialization page for user code

'Setting the report source report = new reportDocument () Report.load (getReportPath (RPT_NAME))

'Setting Parameters CRVORDERS.PARAMETERFIELDINFO = GetParameterInfo (CTYPE ("List", ListItemcollection))

CRVORDERS.REPORTSOURCE = Report

'Show report CRVORDERS.DATABIND ()

End sub '----------------------------------------------- ----------------- 'Function GetParameterInfo:' From the checkbox list Get the parameter field information 'returns:' parameter field 'parameters:' [in] list: check box list 'Throws:' 'preconditions:' '--------------------------------------- ----------------------- Private Function GetParameterInfo (Byval List As ListItemcollection) AS Parameterfields

DIM ITEM As ListItem Dim ISempty As Boolean = True Dim Itemcount As INTEGER = 0

'The declaration passed the parameters to the variables required for the viewer control. Dim paramfields as new parameterfields () Dim paramfield as new parameterfield () DIM DISCRETEVAL As New ParameterDiscretevalue ()

'The parameter is a discrete parameter with multiple values.

'Set the name of the parameter field, it must match the parameters in the report. PARAMFIELD.PARAMELDNAME = parameter_field_name

For Each Item in list if item.selected the means = false itemcount = 1

'A set of discrete values ​​and pass it to the parameter discreteVal.Value = item.Value paramField.CurrentValues.Add (discreteVal)' Create a new discrete value discreteVal = New ParameterDiscreteValue () End If NextIf isEmpty Then For Each item In list 'provided A discrete value and passes it to this parameter discreteval.value = item.Value paramfield.currentValues.add (discreteval) 'New a discrete value discreteval = new parameterdiscretevalue () Next End IF

'Add this parameter to the parameter field collection. Paramfields.Add (paramfield) getParameterInfo = paramfields

END FUNCTION

转载请注明原文地址:https://www.9cbs.com/read-22483.html

New Post(0)