【Stimulsoft Reports.WinForms教程】Detalization实时报表

【下载Stimulsoft Reports.Ultimate最新版本】

此示例项目显示如何在单独的预览窗口中进行报表分离。该报告可能包含外部报表中的详细数据。例如,主要和详细报表显示在单独的预览窗口中。加载主报表,为click事件添加事件侦听器,并在查看器中显示此报表:

private void button2_Click(object sender, System.EventArgs e)
{
    StiReport report = new StiReport();
    report.RegData(dataSet1);
    report.Load("..\\LiveReports.mrt");
    report.Compile();
    report.CompiledReport.Click += new EventHandler(click);
    report.Show();
}

在click事件中,您可以使用主报表中的参数加载包含数据过滤的详细报表:

private void click(object sender, EventArgs e)
{
    StiComponent comp = sender as StiComponent;
    string customerID = (string)comp.BookmarkValue;
 
    if (customerID != null)
    {
        StiReport report = new StiReport();
        report.RegData(dataSet1);
        report.Load("..\\Details.mrt");
        StiDataBand dataBand = (StiDataBand)report.Pages["Page1"].Components["DataBand1"];
        StiFilter filter = new StiFilter("{Orders.CustomerID==\"" + customerID + "\"}");
        dataBand.Filters.Add(filter);
        report.Show();
    }
}

示例代码的结果如下图所示:

Stimulsoft

查看原文,下载示例