CrystalReportViewer.OnDrill Method
Synchronizes the Drill event between two CrystalReportViewer controls by acting as the default event handler for the second control.
Namespace CrystalDecisions.Web Assembly CrystalDecisions.Web (CrystalDecisions.Web.dll)
Syntax
'Declaration
Public Overrideable Sub OnDrill ( _
ByVal source As Object, _
ByVal e As CrystalDecisions.Web.DrillEventArgs _
)
public virtual void OnDrill (
object source,
CrystalDecisions.Web.DrillEventArgs e
)
Parameters
- source
The CrystalReportViewer control.
- e
The data that is related to the Drill event.
Remarks
When the Drill event is fired in a CrystalReportViewer (call it CrystalReportViewer1) the OnDrill method acts as the default event handler for another CrystalReportViewer (call it CrystalReportViewer2). This scenario occurs when a new DrillEventHandler is created for CrystalReportViewer1 that uses the address of the OnDrill method of CrystalReportViewer2 as the argument. When the user drills down on the subreport in CrystalReportViewer1 the subreport in CrystalReportViewer2 will mirror the activity of the report in CrystalReportViewer1. Any Drill event code in CrystalReportViewer2 is ignored, as the event in CrystalReportViewer2 is not fired. If the user drills down on the subreport in CrystalReportViewer2 then the Drill event for CrystalReportViewer2 and any subsequent code will execute.
This method can be used to help compare data between two reports. For example a Web application displays two monthly sales reports, one for December and one for January. When the report in the December sales report is drilled into the January report mirrors the actions of the December report. The user is able to compare the sales figures between the two reports without having to duplicate their actions for each report.
Example
This example demonstrates how to create the new DrillEventHandler for CrystalReportViewer1 that will delegate the event to CrystalReportViewer2 through the OnDrill method. The example sets the report source for the CrystalReportViewer control and then creates the event handler.
'Declaration
Private Sub Page_Load _
(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
Me.CrystalReportViewer1.ReportSource = _
Me.MapPath("DecemberSales.rpt")
Me.CrystalReportViewer2.ReportSource = _
Me.MapPath("JanuarySales.rpt")
AddHandler CrystalReportViewer1.Drill, _
AddressOf(CrystalReportViewer2.OnDrill)
End Sub
private void Page_Load(object sender, System.EventArgs e)
{
CrystalReportViewer1.ReportSource =
this.MapPath("DecemberSales.rpt");
CrystalReportViewer2.ReportSource =
this.MapPath("JanuarySales.rpt");
this.CrystalReportViewer1.Drill += new
CrystalDecisions.Web.DrillEventHandler
(CrystalReportViewer2.OnDrill);
}
Version Information
Crystal Reports Basic for Visual Studio 2008
Supported since: Crystal Reports for Visual Studio .NET 2002
See Also
Reference
CrystalReportViewer Class
CrystalReportViewer Members
CrystalDecisions.Web Namespace