Share via


ParameterFieldDefinition Class

Represents a parameter field in the report. This object provides properties and methods for retrieving information and setting options for a parameter field in a report.

Namespace CrystalDecisions.CrystalReports.Engine Assembly CrystalDecisions.CrystalReports.Engine (CrystalDecisions.CrystalReports.Engine.dll)

Syntax

'Declaration
Public Class ParameterFieldDefinition
    Inherits FieldDefinition
    Implements IDisposable, IParameterField
public class ParameterFieldDefinition : FieldDefinition, IDisposable, IParameterField

Remarks

Retrieve a ParameterFieldDefinition object by index or by name through the Item property of the ParameterFieldDefinitions collection.

Example

This example shows how to set the following values: the current values for a ranged parameter, the multiple default values for a discrete parameter in a subreport, and the minimum and maximum values for a discrete parameter.

'Declaration

              Private Sub SetParameters( _
                 ByVal startValue As Double, ByVal endValue As Double, _
                 ByVal discreteValue1 As Integer, _
                 ByVal discreteValue2 As Integer, _
                 ByVal minValue As Integer, ByVal maxValue As Integer)

                 Dim discreteParam As New ParameterDiscreteValue()
                 Dim rangeParam As New ParameterRangeValue()
                 Dim paramField As ParameterFieldDefinition
                 Dim currentValues As ParameterValues
                 Dim defaultValues As ParameterValues

                 paramField = _
                    Report.DataDefinition.ParameterFields.Item("RangedParam")
                 rangeParam.StartValue = startValue
                 rangeParam.EndValue = endValue
                 currentValues = paramField.CurrentValues
                 currentValues.Add(rangeParam)
                 paramField.ApplyCurrentValues(currentValues)

                 paramField = _
                    Report.DataDefinition.ParameterFields.Item("DiscreteParam", "sub1")

                 paramField.ApplyMinMaxValues(minValue, maxValue)

                 discreteParam.Value = discreteValue1
                 defaultValues = paramField.DefaultValues
                 defaultValues.Add(discreteParam)
                 paramField.ApplyDefaultValues(defaultValues)

                 discreteParam = New ParameterDiscreteValue()
                 discreteParam.Value = discreteValue2
                 defaultValues = paramField.DefaultValues
                 defaultValues.Add(discreteParam)
                 paramField.ApplyDefaultValues(defaultValues)
      End Sub

      
            void SetParameters(float startValue, float endValue,
               int discreteValue1, int discreteValue2, int minValue,
               int maxValue)
            {
               ParameterDiscreteValue* discreteParam = new
                  ParameterDiscreteValue();
               ParameterRangeValue* rangeParam = new ParameterRangeValue();
               ParameterFieldDefinition* paramField;
               ParameterValues* currentValues;
               ParameterValues* defaultValues;

               paramField =
                  Report->DataDefinition->ParameterFields->Item["RangedParam"];
               rangeParam->StartValue = __box(startValue);
               rangeParam->EndValue = __box(endValue);
               currentValues = paramField->CurrentValues;
               currentValues->Add(rangeParam);
                  paramField->ApplyCurrentValues(currentValues);

               paramField = Report->DataDefinition->ParameterFields->Item
                  ["DiscreteParam", "sub1"];

               paramField->ApplyMinMaxValues(__box(minValue), __box(maxValue));

               discreteParam->Value = __box(discreteValue1);
               defaultValues = paramField->DefaultValues;
               defaultValues->Add(discreteParam);
               paramField->ApplyDefaultValues(defaultValues);

               discreteParam = new ParameterDiscreteValue();
               discreteParam->Value = __box(discreteValue2);
               defaultValues = paramField->DefaultValues;
               defaultValues->Add(discreteParam);
               paramField->ApplyDefaultValues(defaultValues);
            };
      
              private void SetParameters(float startValue, float endValue,
                 int discreteValue1, int discreteValue2, int minValue,
                 int maxValue)
              {
                 ParameterDiscreteValue discreteParam = new
                    ParameterDiscreteValue();
                 ParameterRangeValue rangeParam = new ParameterRangeValue();
                 ParameterFieldDefinition paramField;
                 ParameterValues currentValues;
                 ParameterValues defaultValues;

                 paramField =
                    Report.DataDefinition.ParameterFields["RangedParam"];
                 rangeParam.StartValue = startValue;
                 rangeParam.EndValue = endValue;
                 currentValues = paramField.CurrentValues;
                 currentValues.Add(rangeParam);
                 paramField.ApplyCurrentValues(currentValues);

                 paramField = Report.DataDefinition.ParameterFields
                    ["DiscreteParam", "sub1"];

                 paramField.ApplyMinMaxValues(minValue, maxValue);

                 discreteParam.Value = discreteValue1;
                 defaultValues = paramField.DefaultValues;
                 defaultValues.Add(discreteParam);
                 paramField.ApplyDefaultValues(defaultValues);

                 discreteParam = new ParameterDiscreteValue();
                 discreteParam.Value = discreteValue2;
                 defaultValues = paramField.DefaultValues;
                 defaultValues.Add(discreteParam);
                 paramField.ApplyDefaultValues(defaultValues);
      }
      

Inheritance Hierarchy

Object
   EngineObjectBase
      FieldDefinition
         ParameterFieldDefinition

Version Information

Crystal Reports Basic for Visual Studio 2008

Supported since: Crystal Reports for Visual Studio .NET 2002

See Also

Reference

ParameterFieldDefinition Members
CrystalDecisions.CrystalReports.Engine Namespace