ActiveReportsのイベント発生順序ですが、非常にややこしいです。基本的なformat,before,afterのイベント発生順序は以下のようです。
(セクション名)_Format
(セクション名)_BeforePrint
(セクション名)_AfterPrint
帳票にグループヘッダがあるとさらにややこしいです。
グループヘッダ(OnPage)有りの2ページの帳票があるとします。1ページ目は3行、2ページ目は4行とします。
この帳票のイベント発生順序は以下の通りです。
DataInitialize
FetchData(1ページ目1行目)
BeforePrint(グループヘッダ)
detail_Format
detail_BeforePrint
FetchData(1ページ目2行目)
detail_Format
detail_BeforePrint
FetchData(1ページ目3行目)
detail_Format
detail_BeforePrint
FetchData(2ページ目1行目)
BeforePrint(グループヘッダ)
detail_Format
detail_BeforePrint
FetchData(2ページ目2行目)
detail_Format
detail_BeforePrint
FetchData(2ページ目3行目)
detail_Format
detail_BeforePrint
FetchData(2ページ目4行目)
detail_Format
detail_BeforePrint
FetchData(2ページ目5行目存在しないがデータの終わりeArgs.EOF = trueで実行されるので注意)
グループヘッダのイベントだけはページ単位で行われていることがわかります。