Our WinForms ReportViewer exposes four events: Export, Print, RenderingBegin and UpdateUI
Export event
The Export event occurs when the report shown in the ReportViewer control is exported. The Export event handler receives two arguments:
- The ReportViewer control that owns the report that is being exported. This argument is of type object, but can be cast to the ReportViewer type.
- Telerik.ReportViewer.WinForms.ExportEventArgs with the following properties:
- Cancel: This boolean property can be set true to abandon exporting
- DeviceInfo: This property can be used to pass rendering parameters to a rendering extension (more info here).
- RenderingExtension: This property is read only and shows export extention info for the exported report. More info is available in the Rendering extensions help article.
Example
CopyC#
private void reportViewer1_Export(object sender, Telerik.ReportViewer.WinForms.ExportEventArgs args)
{
switch (args.RenderingExtension.Name)
{
case "Excel":
break;
case "PDF":
break;
}
CopyVB.NET
Private Sub reportViewer1_Export(sender As Object, args As Telerik.ReportViewer.WinForms.ExportEventArgs)
Select Case args.RenderingExtension.Name
Case "Excel"
Exit Select
Case "PDF"
Exit Select
End Select
End Sub
Print event
The Print event occurs when the report shown in the ReportViewer control is printed. The Print event handler receives two arguments:
- The ReportViewer control that owns the report that is being exported. This argument is of type object, but can be cast to the ReportViewer type.
- System.ComponentModel.CancelEventArgs with a single property:Cancel: This boolean property can be set true to abandon printing
Example
CopyC#
private void reportViewer1_Print(object sender, System.ComponentModel.CancelEventArgs e)
{
e.Cancel = true;
}
CopyVB.NET
Private Sub reportViewer1_Print(sender As Object, e As System.ComponentModel.CancelEventArgs)
e.Cancel = True
End Sub
RenderingBegin event
The RenderingBegin event occurs when the report in the viewer control is rendered. The RenderingBegin event handler receives two arguments:
- The ReportViewer control that owns the report that is being exported. This argument is of type object, but can be cast to the ReportViewer type.
- System.ComponentModel.CancelEventArgs with a single property:Cancel: This boolean property can be set true to abandon rendering
CopyC#
private void reportViewer1_RenderingBegin(object sender, System.ComponentModel.CancelEventArgs e)
{
e.Cancel = true;
}
CopyVB.NET
Private Sub reportViewer1_RenderingBegin(sender As Object, e As System.ComponentModel.CancelEventArgs)
e.Cancel = True
End Sub
UpdateUI event
The UpdateUI event occurs when the UI of the report viewer control is updated. The UpdateUI event handler receives two arguments:
- The ReportViewer control that owns the report that is being exported. This argument is of type object, but can be cast to the ReportViewer type.
- System.EventArgs
See Also