Crystal Reports XI Release 2  

ParameterFields.Add Method

Adds a ParameterField object to the collection.

[Visual Basic]
Public Overrideable Function Add( _
   ByVal parameterField As CrystalDecisions.Shared.ParameterField _
) As Integer
public virtual int Add(
   CrystalDecisions.Shared.ParameterField parameterField



The ParameterField object added to the ParameterFields collection.

Return Value

Indicates the location of the ParameterField in the collection.


The ParameterFields must be set before the ReportSource property of the CrystalReportViewer control; if it is not, the control will prompt for the parameter information.


This example demonstrates how to add a parameter field to the ParameterFields collection. This function takes a ParameterFields collection, a parameter name and a value. It returns the ParameterFields collection with the new parameter.

[Visual Basic]

      Private Function AddParameter(ByVal paramName As String, _
         ByVal paramValue As String, ByVal paramFields As _
         ParameterFields) As ParameterFields
         Dim paramField As New ParameterField()
         Dim paramDiscreteValue As New ParameterDiscreteValue()
         Dim paramValues As New ParameterValues()
         paramField.ParameterFieldName = paramName
         paramDiscreteValue.Value = paramValue
         paramField.CurrentValues = paramValues
         Return paramFields
      End Function

      static ParameterFields* AddParameter
         (String* paramName, String* paramValue,
         ParameterFields* paramFields)
         ParameterField* paramField = new ParameterField ();
         ParameterDiscreteValue* paramDiscreteValue = new 
            ParameterDiscreteValue ();
         ParameterValues* paramValues = new ParameterValues ();
         paramField->ParameterFieldName = paramName;
         paramDiscreteValue->Value = paramValue;
         paramValues->Add (paramDiscreteValue);
         paramField->CurrentValues = paramValues;
         paramFields->Add (paramField);
         return paramFields;

      private ParameterFields AddParameter
         (string paramName, string paramValue,
         ParameterFields paramFields)
         ParameterField paramField= new ParameterField ();
         ParameterDiscreteValue paramDiscreteValue = new
            ParameterDiscreteValue ();
         ParameterValues paramValues = new ParameterValues ();
         paramField.ParameterFieldName = paramName;
         paramDiscreteValue.Value = paramValue
         paramValues.Add (paramDiscreteValue);
         paramField.CurrentValues = paramValues;
         paramFields.Add (paramField);
         return paramFields;


Namespace   CrystalDecisions.Shared

Assembly  CrystalDecisions.Shared (CrystalDecisions.Shared.dll)

See Also

ParameterFields Class | ParameterFields Members | CrystalDecisions.Shared Namespace