質問

フォーマットを正しく発生させるのに苦労しています。それは、私が変更を加えようとしている出来事をおそらく間違っていることに起因するものだと思います。

どんな方向も素晴らしいでしょう

    private void so_FetchData(object sender, FetchEventArgs eArgs)
    {
        if (m_so != null && m_so.Rows.Count > (m_soRowCount + 1))
        {
            DataRow soDr = m_so.Rows[m_soRowCount++];
            if (soDr != null)
            {
                var compResID = (int) soDr["CompResID"];
                var result = (ComplianceLevel) soDr["Result"];
                var sectNum = (int) soDr["JobSectType"];
                var sectName = soDr["S" + sectNum + "Name"] as string;
                var sectTxt = soDr["S" + sectNum + "Text"] as string;

                Fields["CompLev"].Value = (result == ComplianceLevel.OtherThanSerious) ? "Other Than Serious" : result.ToString();

                m_sectInfo = new SectInfo(sectName, sectTxt);
                m_causes = new Causes(compResID);
                m_actions = new Actions(compResID);
                subReport1.Report = m_sectInfo;
                subReport2.Report = m_causes;
                subReport3.Report = m_actions;
                eArgs.EOF = false;
            }
        }
        else
        {
            eArgs.EOF = true;
        }
    }

    private void eh_BeforePrint(object sender, EventArgs e)
    {
        //decide where the bottom border should be draw to
        if (m_actions != null && m_actions.ShouldShowBottBorder)
        {
            subReport3.Border.BottomStyle = BorderLineStyle.ThickSolid;
            subReport2.Border.BottomStyle = BorderLineStyle.Solid;
        }
        else if (m_causes != null && m_causes.ShouldShowBottBorder)
        {
            subReport2.Border.BottomStyle = BorderLineStyle.ThickSolid;
        }
        else
        {
            subReport1.Border.BottomStyle = BorderLineStyle.ThickSolid;
        }
    }

問題は、eh_beforeprintメソッドを踏むたびに、サブレポートを踏み出し、値が適切に設定されている場合でも、値は常にfalseに等しくなることです。ブールプロパティをfalseにリセットするために何が起こっていますか?

各サブレポートのfetch_dataメソッドに印刷するレコードがある場合は、変更するだけです。

    private void Causes_FetchData(object sender, FetchEventArgs eArgs)
    {
        if (m_pos < m_corrs.Count)
        {
            if (!ShouldShowBottBorder)
                ShouldShowBottBorder = true;
            //...
         } 
     }
役に立ちましたか?

解決

対応するFetchDataイベントの後に正確に提起される前のプリントイベントが提起されることを保証することはできません。たとえば、FetchDataは複数のレコードで何度も発射する場合がありますが、レイアウトエンジンでロジックをまとめるものがあるため、ActiveReportsがどのページにセクションをコミットするかを知る前に、いくつかのレコードを取ることがあります。したがって、対応するプリントイベントが発生する前に、FetchDataがいくつかのイベントで提起されることが非常に一般的です。

あなたのコードを適切に理解している場合、より大きな問題があります。サブレポートで値を計算しているように見えます(M_CAUSESとM_ACTIONSは実際のサブレポートのように見えます)。その場合、サブレポートの値を確実に計算して親レポートに渡すことができません。代わりに、親レポートのこれらの値を計算する必要があります。ただし、通常、共有関数を追加して値を計算し、親レポートから呼び出してから、その値をサブレポートに渡すことができます。

それを行うことについて具体的な質問がある場合は、ここにいくつかの情報をコメントしてください。

無関係なメモでは、サブレポートの初期化方法を変更すると、かなり重要なパフォーマンスブーストを得ることができます。レポートスタートイベントのサブレポートを常に初期化し、サブレポートコントロールを含むセクションの形式イベントでデータを設定します。これにより、すべてのレコードの各サブアーポートを初期化する代わりに、各サブレポートを1回初期化します。例えば:

private void so_ReportStart()
{
    subreport1.Report = new SectInfo();
    subreport2.Report = new Causes();
    subreport3.Report = new Actions();
}
private void Detail_Format()
{ // assuming Detail is the section containing your subreports:

    ((SectInfo)subreport1.Report).SetParameters(Fields["sectName"].Value, Fields["sectTxt"].Value);
    ((Causes)subreport2.Report).SetParameters(Fields["compResID"].Value);
    ((Actions)subreport3.Report).SetParameters(Fields["compResID"].Value);
}

これらの「フィールド」値は、現在のサブレポートの初期化と同様に、FetchDataの「フィールド」値をセットアップします。次のようなもの:

private void so_FetchData(object sender, FetchEventArgs eArgs)
{
    if (m_so != null && m_so.Rows.Count > (m_soRowCount + 1))
    {
        DataRow soDr = m_so.Rows[m_soRowCount++];
        if (soDr != null)
        {
            var compResID = (int) soDr["CompResID"];
            var result = (ComplianceLevel) soDr["Result"];
            var sectNum = (int) soDr["JobSectType"];
            var sectName = soDr["S" + sectNum + "Name"] as string;
            var sectTxt = soDr["S" + sectNum + "Text"] as string;

            Fields["CompLev"].Value = (result == ComplianceLevel.OtherThanSerious) ? "Other Than Serious" : result.ToString();
            /** BEGIN NEW CODE **/
            Fields["sectName"].Value = sectName;
            Fields["sectTxt"].Value = sectTxt;
            Fields["compResID"].Value = compResId;
            /** END NEW CODE **/

            /** OLD CODE:
            m_sectInfo = new SectInfo(sectName, sectTxt);
            m_causes = new Causes(compResID);
            m_actions = new Actions(compResID);
            subReport1.Report = m_sectInfo;
            subReport2.Report = m_causes;
            subReport3.Report = m_actions;
            **/     
            eArgs.EOF = false;
        }
    }
    else
    {
        eArgs.EOF = true;
    }
}

ActiveReportsのイベントの詳細については、参照してください Report Events Concepts ActiveReportsオンラインヘルプのトピック. 。データをサブレポートに渡すことの詳細については、参照してください ActiveReportsオンラインヘルプにランタイムデータソースを備えたサブレポート.

Scott Willeke
GrapeCity inc.
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top