作成日: 2026/03/25 最終更新日: 2026/03/25
文書種別
使用方法
詳細
ページレポート/RDLレポートの場合
パラメータを経由してサブレポートのデータセットにフィルタを設定します。
具体的には、以下の3つを設定します。
(1) サブレポート:レポートのパラメータ
(2) サブレポート:データセットのフィルタ
(3) メインレポート:SubReportコントロールのパラメータ
セクションレポートの場合
SubReportコントロールを配置しているセクションのFormatイベントでSQLクエリを変更します。
◆サンプルコード (C#)
GrapeCity.ActiveReports.SectionReport subRpt;
private void SectionReport1_ReportStart(object sender, EventArgs e)
{
subRpt = new YourReportName();
}
private void Detail_Format(object sender, EventArgs e)
{
var childDataSource = (GrapeCity.ActiveReports.Data.OleDBDataSource)subRpt.DataSource;
childDataSource.SQL = "SELECT * FROM Products WHERE CategoryID = " + this.txtCategoryID1.Value.ToString();
subReport1.Report = subRpt;
}◆サンプルコード (VB.NET)
Private subRpt As GrapeCity.ActiveReports.SectionReport
Private Sub SectionReport1_ReportStart(sender As Object, e As EventArgs) Handles MyBase.ReportStart
subRpt = New YourReportName()
End Sub
Private Sub detail_Format(sender As Object, e As EventArgs) Handles detail.Format
Dim childDataSource = CType(subRpt.DataSource, GrapeCity.ActiveReports.Data.OleDBDataSource)
childDataSource.SQL = "SELECT * FROM Products WHERE CategoryID = " + Me.txtCategoryID1.Value.ToString()
subReport1.Report = subRpt
End Sub
※注意
FormatイベントでFieldプロパティを参照することは推奨されません。
SubReportと同じセクションに配置しているTextBoxを経由して値を取得してください。


