SubreportProcessing Events
Collapse the table of content
Expand the table of content
The document is archived and information here might be outdated

LocalReport.SubreportProcessing Event 

Occurs when a subreport is processed.

Namespace: Microsoft.Reporting.WinForms
Assembly: Microsoft.ReportViewer.WinForms (in microsoft.reportviewer.winforms.dll)

Public Event SubreportProcessing As SubreportProcessingEventHandler
Dim instance As LocalReport
Dim handler As SubreportProcessingEventHandler

AddHandler instance.SubreportProcessing, handler

/** @event */
public void add_SubreportProcessing (SubreportProcessingEventHandler value)

/** @event */
public void remove_SubreportProcessing (SubreportProcessingEventHandler value)

JScript supports the use of events, but not the declaration of new ones.

You must supply data for any data sources used in subreports. To do this, you must supply an event handler for the SubreportProcessing event.

You can examine values of parameters passed to the subreport by examining the Parameters property and supplying data corresponding to those parameter values.

If the main report has several subreports, you can examine the ReportPath property of the SubreportProcessingEventArgs class to determine which subreport is being processed and supply data for that subreport.

For more information about the arguments passed to this event handler, see SubreportProcessingEventArgs.

The following code example implements a master/detail report using subreports. The code loads a sample report that contains a subreport and sets up an event handler to handle the SubreportProcessing event. The arguments passed to the SubreportProcessing event handler include an object encapsulating the subreport. The event handler adds a data source instance to this subreport before it is rendered in the ReportViewer control.

Option Explicit On
Imports System
Imports System.Drawing
Imports Microsoft.Reporting.WinForms

Public Class Form1
    Inherits System.Windows.Forms.Form

    Private orderDetailsData As DataTable = Nothing
    Friend WithEvents ReportViewer1 As Microsoft.Reporting.WinForms.ReportViewer

    Function LoadOrdersData() As DataTable
        ' Load
        Dim dataSet As New DataSet()
        Return dataSet.Tables(0)

    End Function

    Function LoadOrderDetailsData() As DataTable
        Dim dataSet As New DataSet()
        Return dataSet.Tables(0)
    End Function

    Public Sub DemoSubreportProcessingEventHandler(ByVal sender As Object, _
     ByVal e As SubreportProcessingEventArgs)

        If orderDetailsData Is Nothing Then
            orderDetailsData = LoadOrderDetailsData()
        End If
        e.DataSources.Add(New ReportDataSource("DataSet1_OrderDetails", orderDetailsData))
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Me.ReportViewer1 = New Microsoft.Reporting.WinForms.ReportViewer
        Me.ReportViewer1.Dock = System.Windows.Forms.DockStyle.Fill

        Me.Text = "Report Control Demo"
        Me.ClientSize = New System.Drawing.Size(700, 600)
        Me.ReportViewer1.ProcessingMode = ProcessingMode.Local
        Me.ReportViewer1.LocalReport.ReportPath = "c:\MyReports\Orders.rdlc"
        AddHandler Me.ReportViewer1.LocalReport.SubreportProcessing, AddressOf DemoSubreportProcessingEventHandler
        Me.ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource("DataSet1_Orders", LoadOrdersData()))

    End Sub

End Class
© 2016 Microsoft