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
[C#]
public virtual int Add(
   CrystalDecisions.Shared.ParameterField parameterField
);

Parameters

parameterField

The ParameterField object added to the ParameterFields collection.

Return Value

Indicates the location of the ParameterField in the collection.

Remarks

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.

Example

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
         paramValues.Add(paramDiscreteValue)
         paramField.CurrentValues = paramValues
      
         paramFields.Add(paramField)
         Return paramFields
      
      End Function
      
        
[C++]

      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;
      };
      
        
[C#]

      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;
      }
      

Requirements

Namespace   CrystalDecisions.Shared

Assembly  CrystalDecisions.Shared (CrystalDecisions.Shared.dll)

See Also

ParameterFields Class | ParameterFields Members | CrystalDecisions.Shared Namespace