cancel
Showing results for 
Search instead for 
Did you mean: 

Does anybody know what DefaultValueDisplayType is?

Former Member
0 Kudos

I have some code that is trying to work around a bug in Crystal Reports (see below).  The old version of Crystal Reports XI R2 used to prompt the user for required parameter values before printing or exporting but CR 2008 does not.  To get around this I preview the report which still prompts the user for parameter values.  I found a variable that I think tells me whether I need to prompt the user but I'm not sure.  Is DefaultValueDisplayType a flag that indicates if this parameter has not yet been filled in and needs user input?

for (int c = 0; c < m_ReportDocument.ParameterFields.Count; c++)
{
     if (m_ReportDocument.ParameterFields[c].DefaultValueDisplayType == 0)
     {
          bParamNeeded = true;
          break;
     }
}

if (bParamNeeded)
     ShowRepport();  // this will prompt the user for values
.
.
.

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hi Matt,

Try this:

if (rptClientDoc.DataDefController.DataDefinition.ParameterFields.Count > 0) //there are parameters
{
    foreach (CrystalDecisions.ReportAppServer.DataDefModel.ParameterField paramfield in rptClientDoc.DataDefController.DataDefinition.ParameterFields)
    {
        switch (paramfield.ValueRangeKind)
        {
            case CrParameterValueRangeKindEnum.crParameterValueRangeKindDiscrete:
                {
                    getDiscreteValues(paramfield);
                    break;
                }
            case CrParameterValueRangeKindEnum.crParameterValueRangeKindDiscreteAndRange:
                {
                    getRangeAndDiscreteValues(paramfield);
                    break;
                }
            case CrParameterValueRangeKindEnum.crParameterValueRangeKindRange:
                {
                    getRangeValues(paramfield);
                    break;
                }
        }
    }
}
private void getDiscreteValues(CrystalDecisions.ReportAppServer.DataDefModel.ISCRParameterField paramfield)
{
    string textBox1 = String.Empty;
    string name = paramfield.Name;
    int currValCount = paramfield.InitialValues.Count;
    int defValCount = paramfield.DefaultValues.Count;
    if (currValCount > 0)  //this parameter has default values
    {
        foreach (ParameterFieldDiscreteValue discreteDefaultVal in paramfield.InitialValues)
        {
            btnReportObjects.AppendText(paramfield.Name.ToString());
            textBox1 = ": " + discreteDefaultVal.Value.ToString();
            btnReportObjects.Text += textBox1;
            btnReportObjects.AppendText("\n");
            //MessageBox.Show(discreteDefaultVal.Value.ToString());
        }
    }
    else
    {
        btnReportObjects.AppendText(paramfield.Name.ToString());
        btnReportObjects.AppendText(": No Initial Value \n");
    }
}

btnReportObjects is a text box only.

Don

Answers (1)

Answers (1)

former_member184995
Active Contributor
0 Kudos

I believe that allows you to set if you want the parameter to show just the value or the value and description of the parameter.

Former Member
0 Kudos

Thanks Jason, is that a way for me to know if the parameter needs to be filled in by the user or is there something else I can use to determine that?