Share via


CrystalReportViewer.OnRefresh Method

Synchronizes the ReportRefresh 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 OnRefresh ( _
    ByVal source As Object, _   
    ByVal e As CrystalDecisions.Web.ViewerEventArgs _   
) 
public virtual void OnRefresh (
    object source,
    CrystalDecisions.Web.ViewerEventArgs e
)

Parameters

  • source
    The CrystalReportViewer control.
  • e
    The data that is related to the ReportRefresh event.

Remarks

When the ReportRefresh event is fired in a CrystalReportViewer (call it CrystalReportViewer1) the OnRefresh method acts as the default event handler for another CrystalReportViewer (call it CrystalReportViewer2). This scenario occurs when a new RefreshEventHandler is created for CrystalReportViewer1 that uses the address of the OnRefresh method of CrystalReportViewer2 as the argument. When the user refreshes the report in CrystalReportViewer1 the report in CrystalReportViewer2 will mirror the activity of the report in CrystalReportViewer1. Any ReportRefresh event code in CrystalReportViewer2 is ignored, as the event in CrystalReportViewer2 is not fired. If the user refreshes the report in CrystalReportViewer2 then the ReportRefresh 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 sales reports, one for the western region and one for the eastern region. When the western region sales report is refreshed the eastern region sales report mirrors the actions of the western region sales 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 RefreshEventHandler for CrystalReportViewer1 that will delegate the event to CrystalReportViewer2 through the OnRefresh 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("WesternSales.rpt")
         Me.CrystalReportViewer2.ReportSource =  _
            Me.MapPath("EasternSales.rpt")
         AddHandler CrystalReportViewer1.ReportRefresh, _
            AddressOf(CrystalReportViewer2.OnRefresh)
      
      End Sub
      private void Page_Load(object sender, System.EventArgs e)
      {
         CrystalReportViewer1.ReportSource = 
            this.MapPath("WesternSales.rpt");
         CrystalReportViewer2.ReportSource = 
            this.MapPath("EasternSales.rpt");
         this.CrystalReportViewer1.ReportRefresh += new 
            CrystalDecisions.Web.RefreshEventHandler
            (CrystalReportViewer2.OnRefresh);
      }

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