Reputation: 1617
I am trying to get the default value description from a Crystal Reports parameter. This is the code that I am using. To test the value I am using a message box. Here is my code. The message box shows up empty.
foreach (ParameterField param in clsCrystal.cryRtp.ParameterFields)
{
if (param.Name.Equals("ShowUp"))
{
MessageBox.Show( param.DefaultValues[0].Description.ToString());
}
}
Edit: I figured out how to get the values of the default values for a parameter field but the description is still evading me. Here is the working code to get the value of the default values.
foreach (ParameterField param in clsCrystal.cryRtp.ParameterFields)
{
if (param.Name.Equals("ShowUp"))
{
foreach (ParameterDiscreteValue Dvalue in param.DefaultValues)
{
MessageBox.Show("the value is " + Dvalue.Value.ToString() + " and the description... " + Dvalue.Description);
}
}
}
Upvotes: 0
Views: 1557
Reputation: 1617
Apparently the ParameterFields is not as robust as DataDefinition.ParameterFields I found the answer at this link. http://scn.sap.com/thread/889809 Seems like ParameterFields is designed to make it easier to add values to parameters, while DataDefinition.ParameterFields are the real objects to play with if you actually want to look around at stuff.
foreach (ParameterFieldDefinition param in clsCrystal.cryRtp.DataDefinition.ParameterFields)
{
if (param.Name.Equals("ShowUp"))
{
foreach (ParameterValue parameterValue in param.DefaultValues)
{
if (!parameterValue.IsRange)
{
ParameterDiscreteValue parameterDiscreteValue = (ParameterDiscreteValue)parameterValue;
MessageBox.Show(parameterDiscreteValue.Description);
}
}
}
}
The incredibly confusing thing about the code and the documentation was that I could actually set and read the Default Descriptions in my code. I just couldn't read them when they were set from the Crystal Reports Designer.
Upvotes: 1