0

Crystal Reports パラメータからデフォルト値の説明を取得しようとしています。これは私が使用しているコードです。値をテストするために、メッセージ ボックスを使用しています。これが私のコードです。メッセージ ボックスは空で表示されます。

foreach (ParameterField param in clsCrystal.cryRtp.ParameterFields)
{
    if (param.Name.Equals("ShowUp"))
    {
        MessageBox.Show( param.DefaultValues[0].Description.ToString());
    }
}

編集:パラメータフィールドのデフォルト値の値を取得する方法を見つけましたが、説明はまだ私を回避しています。デフォルト値の値を取得する作業コードを次に示します。

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

1 に答える 1

1

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.

于 2012-11-20T13:33:33.717 に答える