Creating reports with DrillThrough behaviour

How to implement Drill Through behavior

Routine steps:
  1. Firstly, put ReportViewer on your form.
  2. Then put ReportManager on your form.
  3. Add Report to the report manager (let it be inlineReportSlot with “MainReport” ReportName).
  4. Run Designer for the MainReport.
  5. Create new Report.

Idea:

We are going to use hyperlinks, handle them in our code and render dependent reports.

Let’s put two textboxes and set Hyperlink for them:

  1. #Report1
  2. #Report2

Let’s save our report and return to ReportManager.

Add two more reports to report manager:

  1. Report1
  2. Report2

Put some content in these reports.

Now it’s time to handle Hyperlinks:

public Form1()
{
    InitializeComponent();
    inlineReportSlot1.HyperlinkClick += DrillThroughHandler;
    inlineReportSlot2.HyperlinkClick += DrillThroughHandler;
    inlineReportSlot3.HyperlinkClick += DrillThroughHandler;
    reportViewer1.Source = inlineReportSlot1;
    reportViewer1.RefreshReport();
}
private void DrillThroughHandler(object sender,
      PerpetuumSoft.Reporting.Components.HyperlinkEventArgs e)
{
    switch (e.Hyperlink)
    {
        case "#Report1":                  
            reportViewer1.Source = inlineReportSlot2;
            e.Handled = true;
            reportViewer1.RefreshReport();
            break;
        case "#Report2":                   
            reportViewer1.Source = inlineReportSlot3;
            e.Handled = true;
            reportViewer1.RefreshReport();
            break;
        case "#MainReport":
            reportViewer1.Source = inlineReportSlot1;
            e.Handled = true;
            reportViewer1.RefreshReport();
            break;
        default:
            return;
    }
}

This is all you need to know in order to implement drillthrough behaviour.



You can find sample here:
http://perpetuumsoft.com/Support/DrillThrough.SSR/DrillThrough.zip

Add Feedback