2010-11-30 20 views
0

フォーマットが正常に行われるのに問題があります。私はそれが私が変更を行おうとしていたイベントの、おそらく間違って理解しているものから、茎と考えている。プロパティ値が別のイベントでリセットされる

任意の方向は素晴らしいことだ

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と同じです。 boolプロパティをfalseにリセットする原因は何ですか?

各サブレポートのFetch_Dataメソッドで印刷するレコードがある場合にのみ変更します。

private void Causes_FetchData(object sender, FetchEventArgs eArgs) 
    { 
     if (m_pos < m_corrs.Count) 
     { 
      if (!ShouldShowBottBorder) 
       ShouldShowBottBorder = true; 
      //... 
     } 
    } 
+0

「ShouldShowBottBorder」をどこにも設定していないようです。あなたは私たちにその財産の源泉を示してもらえますか? –

答えて

2

BeforePrintイベントが対応するFetchDataイベントの直後に発生することは保証できません。たとえば、FetchDataはいくつかのレコードに対して何回も起動することがありますが、レイアウトエンジンにロジックをまとめておくために、ActiveReportsがセクションをコミットするページを認識するまでにいくつかのレコードが必要になることがあります。したがって、対応するBeforePrintイベントが発生する前に、いくつかのイベントに対してFetchDataを発生させるのが一般的です。

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

これについて具体的な質問がある場合は、ここにコメントしてください。

サブレポートを初期化する方法を変更すると、関係のないメモでは、パフォーマンスが大幅に向上します。 ReportStartイベントでサブレポートを常に初期化し、サブレポートコントロールを含むセクションの形式イベントでデータを設定します。この方法で、すべてのレコードの各サブポートを初期化するのではなく、各サブレポートを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 the Report Events concepts topic in the ActiveReports Online Helpを参照してください内のイベントについての詳細を学ぶために。 サブレポートにデータを渡す方法の詳細については、Subreports with Run-Time Data Sources in the ActiveReports Online Helpを参照してください。

Scott Willeke 
GrapeCity inc. 
関連する問題