CrystalReportViewer.OnNavigate Method
Synchronizes the Navigate 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 OnNavigate ( _
ByVal source As Object, _
ByVal e As CrystalDecisions.Web.NavigateEventArgs _
)
public virtual void OnNavigate (
object source,
CrystalDecisions.Web.NavigateEventArgs e
)
Parameters
- source
The CrystalReportViewer control.
- e
The data that is related to the Navigate event.
Remarks
When the Navigate event is fired in a CrystalReportViewer (call it CrystalReportViewer1) the OnNavigate method acts as the default event handler for another CrystalReportViewer (call it CrystalReportViewer2). This scenario occurs when a new NavigateEventHandler is created for CrystalReportViewer1 that uses the address of the OnNavigate method of CrystalReportViewer2 as the argument. When the user navigates through the report in CrystalReportViewer1 the report in CrystalReportViewer2 will mirror the activity of the report in CrystalReportViewer1. Any Navigate event code in CrystalReportViewer2 is ignored, as the event in CrystalReportViewer2 is not fired. If the user navigates through the report in CrystalReportViewer2 then the Navigate 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 December sales report is navigated 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 NavigateEventHandler for CrystalReportViewer1 that will delegate the event to CrystalReportViewer2 through the OnNavigate 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.Navigate, _
AddressOf(CrystalReportViewer2.OnNavigate)
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.Navigate += new
CrystalDecisions.Web.NavigateEventHandler
(CrystalReportViewer2.OnNavigate);
}
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