Class ReportViewer
Represents the Silverlight ReportViewer control.
Inheritance
Namespace: Telerik.ReportViewer.Silverlight
Assembly: Telerik.ReportViewer.Silverlight.dll
Syntax
public class ReportViewer : Control, IReportViewer, IReportServiceClientFactory
Constructors
ReportViewer()
Initializes a new instance of the ReportViewer class.
Declaration
public ReportViewer()
Fields
ReportProperty
Defines the Report dependency property.
Declaration
public static readonly DependencyProperty ReportProperty
Field Value
System.Windows.DependencyProperty
|
ReportServiceClientFactoryProperty
Defines the ReportServiceClientFactory property.
Declaration
public static readonly DependencyProperty ReportServiceClientFactoryProperty
Field Value
System.Windows.DependencyProperty
|
ReportServiceUriProperty
Defines the ReportServiceUri property.
Declaration
public static readonly DependencyProperty ReportServiceUriProperty
Field Value
System.Windows.DependencyProperty
|
ReportSourceUriProperty
Defines the ReportSourceUri property.
Declaration
public static readonly DependencyProperty ReportSourceUriProperty
Field Value
System.Windows.DependencyProperty
|
TextResourcesProperty
Defines the TextResources property.
Declaration
public static readonly DependencyProperty TextResourcesProperty
Field Value
System.Windows.DependencyProperty
|
UseDefaultPrinterProperty
Defines the UseDefaultPrinter property.
Declaration
public static readonly DependencyProperty UseDefaultPrinterProperty
Field Value
System.Windows.DependencyProperty
|
UseNativePrintingProperty
Defines the UseNativePrinting property.
Declaration
public static readonly DependencyProperty UseNativePrintingProperty
Field Value
System.Windows.DependencyProperty
|
ViewModeProperty
Defines the ViewMode property.
Declaration
public static readonly DependencyProperty ViewModeProperty
Field Value
System.Windows.DependencyProperty
|
ZoomModeProperty
Defines the ZoomMode property.
Declaration
public static readonly DependencyProperty ZoomModeProperty
Field Value
System.Windows.DependencyProperty
|
ZoomPercentProperty
Defines the ZoomPercent property.
Declaration
public static readonly DependencyProperty ZoomPercentProperty
Field Value
System.Windows.DependencyProperty
|
Properties
CurrentPage
Gets or sets the current page in the viewer.
Declaration
public int CurrentPage { get; set; }
Property Value
System.Int32
|
Examples
// Navigate to a desired page
private void button2_Click(object sender, System.EventArgs e)
{
var desiredPage = 5;
// Check if the viewer can navigate to the page since the report may have fewer pages for example
if (this.ReportViewer1.CanMoveToPage(desiredPage))
{
// By setting the property the viewer will automatically navigate to the page in question
this.ReportViewer1.CurrentPage = desiredPage;
}
}
' Navigate to a desired page
Private Sub button2_Click(sender As Object, e As System.EventArgs)
Dim desiredPage = 5
' Check if the viewer can navigate to the page since the report may have fewer pages for example
If Me.ReportViewer1.CanMoveToPage(desiredPage) Then
' By setting the property the viewer will automatically navigate to the page in question
Me.ReportViewer1.CurrentPage = desiredPage
End If
End Sub
DocumentMapVisible
Gets or sets a value that indicates whether the document map is displayed if any bookmark is defined.
Declaration
public bool DocumentMapVisible { get; set; }
Property Value
System.Boolean
|
Examples
' Toggle the document map
Private Sub button9_Click(sender As Object, e As System.EventArgs)
Me.ReportViewer1.DocumentMapVisible = Not Me.ReportViewer1.DocumentMapVisible
End Sub
// Toggle the document map
private void button9_Click(object sender, System.EventArgs e)
{
this.ReportViewer1.DocumentMapVisible = !this.ReportViewer1.DocumentMapVisible;
}
NavigateBackEnabled
NavigateForwardEnabled
ParametersAreaVisible
Gets or sets a value that indicates whether the parameters area is displayed if any parameter editor exists.
Declaration
public bool ParametersAreaVisible { get; set; }
Property Value
System.Boolean
|
Examples
' Toggle the parameters area
Private Sub button10_Click(sender As Object, e As System.EventArgs)
Me.ReportViewer1.ParametersAreaVisible = Not Me.ReportViewer1.ParametersAreaVisible
End Sub
// Toggle the parameters area
private void button10_Click(object sender, System.EventArgs e)
{
this.ReportViewer1.ParametersAreaVisible = !this.ReportViewer1.ParametersAreaVisible;
}
Report
Specifies the assembly qualified name of the report class which should be displayed by the viewer.
Declaration
public string Report { get; set; }
Property Value
System.String
|
ReportServerUri
Specifies the System.Uri to the Telerik WCF Report service. The Uri may be absolute or relative. For complete information on how the relative Uris are resolved to absolute please see EnsureAbsoluteUri(Uri) method.
Declaration
public Uri ReportServerUri { get; set; }
Property Value
System.Uri
|
See Also
ReportServiceClientFactory
Gets or sets the IReportServiceClientFactory that ReportViewer will use the next time a new instance of ReportServiceClient is required.
Declaration
public IReportServiceClientFactory ReportServiceClientFactory { get; set; }
Property Value
IReportServiceClientFactory
|
Remarks
The ReportViewer usually passes absolute Uri to the Create(Uri) method. For more information on how ReportServiceUri is resolved to absolute see EnsureAbsoluteUri(Uri).
Examples
This example illustrates how to implement and use a custom IReportServiceClientFactory.
using System;
using System.ServiceModel;
using System.Windows.Controls;
using Telerik.Reporting.Service.SilverlightClient;
using Telerik.ReportViewer.Silverlight;
public partial class MainPage : UserControl, IReportServiceClientFactory
{
public MainPage()
{
InitializeComponent();
this.ReportViewer1.ReportServiceClientFactory = this;
}
ReportServiceClient IReportServiceClientFactory.Create(System.Uri remoteAddress)
{
var binding = new BasicHttpBinding() // or BasicHttpBinding(BasicHttpSecurityMode.Transport) overload if SSL is used
{
MaxBufferSize = int.MaxValue,
MaxReceivedMessageSize = int.MaxValue,
ReceiveTimeout = new TimeSpan(0, 15, 0),
SendTimeout = new TimeSpan(0, 15, 0)
};
var endpointAddress = new EndpointAddress(remoteAddress);
return new ReportServiceClient(binding, endpointAddress);
}
}
Imports System
Imports System.ServiceModel
Imports System.Windows.Controls
Imports Telerik.Reporting.Service.SilverlightClient
Imports Telerik.ReportViewer.Silverlight
Partial Public Class MainPage
Inherits UserControl
Implements IReportServiceClientFactory
Public Sub New()
InitializeComponent()
Me.ReportViewer1.ReportServiceClientFactory = Me
End Sub
Function Create(ByVal remoteAddress As Uri) As ReportServiceClient Implements IReportServiceClientFactory.Create
Dim binding = New BasicHttpBinding()
binding.MaxBufferSize = Integer.MaxValue
binding.MaxReceivedMessageSize = Integer.MaxValue
binding.ReceiveTimeout = New TimeSpan(0, 15, 0)
binding.SendTimeout = New TimeSpan(0, 15, 0)
Dim endpointAddress As New EndpointAddress(remoteAddress)
Return New ReportServiceClient(binding, endpointAddress)
End Function
End Class
ReportServiceUri
Specifies the System.Uri to the Telerik WCF Report service. The Uri may be absolute or relative. For complete information on how the relative Uris are resolved to absolute please see EnsureAbsoluteUri(Uri) method.
Declaration
public Uri ReportServiceUri { get; set; }
Property Value
System.Uri
|
See Also
TextResources
Gets or sets the tooltips and the messages of the control.
Declaration
public ITextResources TextResources { get; set; }
Property Value
ITextResources
|
TotalPages
Gets the count of the available pages in the viewer.
Declaration
public int TotalPages { get; }
Property Value
System.Int32
|
Examples
' Go to the middle of the report
Private Sub button11_Click(sender As Object, e As System.EventArgs)
Dim middlePage = Me.ReportViewer1.TotalPages / 2
Me.ReportViewer1.CurrentPage = middlePage
End Sub
// Go to the middle of the report
private void button11_Click(object sender, System.EventArgs e)
{
var middlePage = this.ReportViewer1.TotalPages / 2;
this.ReportViewer1.CurrentPage = middlePage;
}
UseDefaultPrinter
Specifies whether or not to automatically print to the default printer for the computer without showing a print dialog. Requires elevated permissions. If the application is partially trusted the property is ignored.
Declaration
public bool UseDefaultPrinter { get; set; }
Property Value
System.Boolean
|
UseNativePrinting
Specifies whether to use native Silverlight printing or not.
Declaration
public bool UseNativePrinting { get; set; }
Property Value
System.Boolean
|
ViewMode
Specifies whether the viewer is in interactive or print preview mode.
Declaration
public ViewMode ViewMode { get; set; }
Property Value
ViewMode
|
Examples
' Switch to interactive mode
Private Sub button12_Click(sender As Object, e As System.EventArgs)
Me.ReportViewer1.ViewMode = Telerik.ReportViewer.Silverlight.ViewMode.Interactive
End Sub
// Switch to interactive mode
private void button12_Click(object sender, System.EventArgs e)
{
this.ReportViewer1.ViewMode = Telerik.ReportViewer.Silverlight.ViewMode.Interactive;
}
ZoomMode
Gets or sets the zoom mode of the control.
Declaration
public ZoomMode ZoomMode { get; set; }
Property Value
ZoomMode
|
Examples
' Set the zoom mode to PageWidth
Private Sub button14_Click(sender As Object, e As System.EventArgs)
Me.ReportViewer1.ZoomMode = Telerik.ReportViewer.Silverlight.ZoomMode.PageWidth
End Sub
// Set the zoom mode to PageWidth
private void button14_Click(object sender, System.EventArgs e)
{
this.ReportViewer1.ZoomMode = Telerik.ReportViewer.Silverlight.ZoomMode.PageWidth;
}
ZoomPercent
Gets or sets the zoom percentage to use when displaying the report.
Declaration
public int ZoomPercent { get; set; }
Property Value
System.Int32
|
Examples
' Set the zoom percent to a specific value
Private Sub button13_Click(sender As Object, e As System.EventArgs)
Me.ReportViewer1.ZoomMode = Telerik.ReportViewer.Silverlight.ZoomMode.Percent
Me.ReportViewer1.ZoomPercent = 140
End Sub
// Set the zoom percent to a specific value
private void button13_Click(object sender, System.EventArgs e)
{
this.ReportViewer1.ZoomMode = Telerik.ReportViewer.Silverlight.ZoomMode.Percent;
this.ReportViewer1.ZoomPercent = 140;
}
Methods
add_ApplyParameters(ApplyParametersEventHandler)
Declaration
public void add_ApplyParameters(ApplyParametersEventHandler value)
Parameters
ApplyParametersEventHandler
value
|
add_Error(ErrorEventHandler)
add_ExportBegin(ExportBeginEventHandler)
Declaration
public void add_ExportBegin(ExportBeginEventHandler value)
Parameters
ExportBeginEventHandler
value
|
add_InteractiveActionEnter(InteractiveActionEnterEventHandler)
Declaration
public void add_InteractiveActionEnter(InteractiveActionEnterEventHandler value)
Parameters
InteractiveActionEnterEventHandler
value
|
add_InteractiveActionExecuting(InteractiveActionExecutingEventHandler)
Declaration
public void add_InteractiveActionExecuting(InteractiveActionExecutingEventHandler value)
Parameters
InteractiveActionExecutingEventHandler
value
|
add_InteractiveActionLeave(InteractiveActionLeaveEventHandler)
Declaration
public void add_InteractiveActionLeave(InteractiveActionLeaveEventHandler value)
Parameters
InteractiveActionLeaveEventHandler
value
|
add_PrintBegin(CancelEventHandler)
Declaration
public void add_PrintBegin(CancelEventHandler value)
Parameters
CancelEventHandler
value
|
add_RenderBegin(RenderBeginEventHandler)
Declaration
public void add_RenderBegin(RenderBeginEventHandler value)
Parameters
RenderBeginEventHandler
value
|
add_RenderingBegin(CancelEventHandler)
Declaration
public void add_RenderingBegin(CancelEventHandler value)
Parameters
CancelEventHandler
value
|
CanMoveToPage(Int32)
Determines whether the viewer can be navigated to a specified page.
Declaration
public bool CanMoveToPage(int pageIndex)
Parameters
System.Int32
pageIndex
The page number to determine navigation possibility. |
Returns
System.Boolean
Returns true if the viewer can be moved to the specified page. |
Examples
// Navigate to a desired page
private void button2_Click(object sender, System.EventArgs e)
{
var desiredPage = 5;
// Check if the viewer can navigate to the page since the report may have fewer pages for example
if (this.ReportViewer1.CanMoveToPage(desiredPage))
{
// By setting the property the viewer will automatically navigate to the page in question
this.ReportViewer1.CurrentPage = desiredPage;
}
}
' Navigate to a desired page
Private Sub button2_Click(sender As Object, e As System.EventArgs)
Dim desiredPage = 5
' Check if the viewer can navigate to the page since the report may have fewer pages for example
If Me.ReportViewer1.CanMoveToPage(desiredPage) Then
' By setting the property the viewer will automatically navigate to the page in question
Me.ReportViewer1.CurrentPage = desiredPage
End If
End Sub
EnsureAbsoluteUri(Uri)
Determines whether the given System.Uri is absolute. If not, creates a new absolute System.Uri based on the combination of System.Windows.Interop.SilverlightHost.Source for the current application and the given relative URI.
Declaration
public static Uri EnsureAbsoluteUri(Uri uri)
Parameters
System.Uri
uri
The System.Uri that is being checked. |
Returns
System.Uri
An absolute System.Uri. |
Remarks
If the URI is absolute, the same instance is returned.
If the URI is relative, a new absolute System.Uri based on the combination of System.Windows.Interop.SilverlightHost.Source of the current application and the given relative URI is created. The System.Windows.Interop.SilverlightHost.Source usually points to the application package (XAP).
Examples
The following example shows some common scenarios and the absolute Uris returned.
Consider that the System.Windows.Interop.SilverlightHost.Source Uri points to http://mydomain/MyWebSite/ClientBin/MyApp.xap
:
//Absolute Uri (no change):
EnsureAbsoluteUri(new Uri("http://mydomain/MyWebSite/ReportService.svc", UriKind.Absolute)); // http://mydomain/MyWebSite/ReportService.svc
//Relative Uris:
EnsureAbsoluteUri(new Uri("ReportService.svc", UriKind.Relative)); // http://mydomain/MyWebSite/ClientBin/ReportService.svc
EnsureAbsoluteUri(new Uri("../ReportService.svc", UriKind.Relative)); // http://mydomain/MyWebSite/ReportService.svc
EnsureAbsoluteUri(new Uri("/ReportService.svc", UriKind.Relative)); // http://mydomain/ReportService.svc
'Absolute Uri (no change):
EnsureAbsoluteUri(New Uri("http://mydomain/MyWebSite/ReportService.svc", UriKind.Absolute)) ' http://mydomain/MyWebSite/ReportService.svc
'Relative Uris:
EnsureAbsoluteUri(New Uri("ReportService.svc", UriKind.Relative)) ' http://mydomain/MyWebSite/ClientBin/ReportService.svc
EnsureAbsoluteUri(New Uri("../ReportService.svc", UriKind.Relative)) ' http://mydomain/MyWebSite/ReportService.svc
EnsureAbsoluteUri(New Uri("/ReportService.svc", UriKind.Relative)) ' http://mydomain/ReportService.svc
ExportReport(String, NameValueDictionary)
Exports the report in the specified format.
Declaration
public void ExportReport(string format, NameValueDictionary deviceInfo)
Parameters
System.String
format
Export format |
NameValueDictionary
deviceInfo
Contains parameters to pass to the rendering extension. |
Examples
// Opens the dialog to export the report
private void button5_Click(object sender, System.EventArgs e)
{
this.ReportViewer1.ExportReport("PDF", null);
}
' Opens the dialog to export the report
Private Sub button5_Click(sender As Object, e As System.EventArgs)
Me.ReportViewer1.ExportReport("PDF", Nothing)
End Sub
NavigateBack()
NavigateForward()
OnApplyParameters(ApplyParametersEventArgs)
This method is called to trigger the ApplyParameters event. Override this method in order to change / add the parameter values that will be used in the upcoming render operation.
Declaration
protected virtual void OnApplyParameters(ApplyParametersEventArgs e)
Parameters
ApplyParametersEventArgs
e
An ApplyParametersEventArgs object that contains the event data. |
Remarks
When overridden, make sure you call the base method implementation.
OnApplyTemplate()
Invoked whenever application code or internal processes call ApplyTemplate.
Declaration
public override void OnApplyTemplate()
OnError(ErrorEventArgs)
Raises the Error event.
Declaration
protected virtual void OnError(ErrorEventArgs e)
Parameters
ErrorEventArgs
e
An ErrorEventArgs object that contains the event data. |
Remarks
When overridden, make sure you call the base method implementation.
OnExportBegin(ExportBeginEventArgs)
Raises the ExportBegin event.
Declaration
protected virtual void OnExportBegin(ExportBeginEventArgs e)
Parameters
ExportBeginEventArgs
e
An ExportBeginEventArgs object that contains the event data. |
Remarks
When overridden, make sure you call the base method implementation.
OnExportEnd(EventArgs)
Raises the ExportEnd event.
Declaration
protected virtual void OnExportEnd(EventArgs e)
Parameters
System.EventArgs
e
An System.EventArgs object that contains the event data. |
Remarks
When overridden, make sure you call the base method implementation.
OnInteractiveActionEnter(InteractiveActionEventArgs)
Raises the InteractiveActionEnter event.
Declaration
protected virtual void OnInteractiveActionEnter(InteractiveActionEventArgs e)
Parameters
InteractiveActionEventArgs
e
The InteractiveActionEventArgs that contains the event data. |
Remarks
When overridden, make sure you call the base method implementation.
OnInteractiveActionExecuting(InteractiveActionCancelEventArgs)
Raises the InteractiveActionExecuting event.
Declaration
protected virtual void OnInteractiveActionExecuting(InteractiveActionCancelEventArgs e)
Parameters
InteractiveActionCancelEventArgs
e
The InteractiveActionCancelEventArgs that contains the event data. |
Remarks
When overridden, make sure you call the base method implementation.
OnInteractiveActionLeave(InteractiveActionEventArgs)
Raises the InteractiveActionLeave event.
Declaration
protected virtual void OnInteractiveActionLeave(InteractiveActionEventArgs e)
Parameters
InteractiveActionEventArgs
e
The InteractiveActionEventArgs that contains the event data. |
Remarks
When overridden, make sure you call the base method implementation.
OnPrintBegin(CancelEventArgs)
Raises the PrintBegin event.
Declaration
protected virtual void OnPrintBegin(CancelEventArgs e)
Parameters
CancelEventArgs
e
An CancelEventArgs object that contains the event data. |
Remarks
When overridden, make sure you call the base method implementation.
OnPrintEnd(EventArgs)
Raises the PrintEnd event.
Declaration
protected virtual void OnPrintEnd(EventArgs e)
Parameters
System.EventArgs
e
An System.EventArgs object that contains the event data. |
Remarks
When overridden, make sure you call the base method implementation.
OnRenderBegin(NameValueDictionary)
This method is called to trigger the RenderBegin method. Override this method in order to perform additional tasks before rendering the report. When overridden, make sure you call the base method implementation.
Declaration
protected virtual bool OnRenderBegin(NameValueDictionary parameterValues)
Parameters
NameValueDictionary
parameterValues
A NameValueDictionary with parameter values for the current report to render. |
Returns
System.Boolean
Return false to cancel the rendering operation otherwise return true. |
OnRenderingBegin(CancelEventArgs)
Raises the RenderingBegin event.
Declaration
protected virtual void OnRenderingBegin(CancelEventArgs e)
Parameters
CancelEventArgs
e
An CancelEventArgs object that contains the event data. |
Remarks
When overridden, make sure you call the base method implementation.
OnRenderingEnd(EventArgs)
Raises the RenderingEnd event.
Declaration
protected virtual void OnRenderingEnd(EventArgs e)
Parameters
System.EventArgs
e
An System.EventArgs object that contains the event data. |
Remarks
When overridden, make sure you call the base method implementation.
OnUpdateUI(EventArgs)
Raises the UpdateUI event.
Declaration
protected virtual void OnUpdateUI(EventArgs e)
Parameters
System.EventArgs
e
An System.EventArgs object that contains the event data. |
Remarks
When overridden, make sure you call the base method implementation.
PrintReport()
Opens the print dialog for the report
Declaration
public void PrintReport()
Examples
// Opens the dialog to print the report
private void button4_Click(object sender, System.EventArgs e)
{
this.ReportViewer1.PrintReport();
}
' Opens the dialog to print the report
Private Sub button4_Click(sender As Object, e As System.EventArgs)
Me.ReportViewer1.PrintReport()
End Sub
RefreshReport()
Refreshes the current report in the viewer. Last used parameter values are used.
Declaration
public void RefreshReport()
Examples
// Refresh the report with the current parameters
private void button6_Click(object sender, System.EventArgs e)
{
this.ReportViewer1.RefreshReport();
}
' Refresh the report with the current parameters
Private Sub button6_Click(sender As Object, e As System.EventArgs)
Me.ReportViewer1.RefreshReport()
End Sub
remove_ApplyParameters(ApplyParametersEventHandler)
Declaration
public void remove_ApplyParameters(ApplyParametersEventHandler value)
Parameters
ApplyParametersEventHandler
value
|
remove_Error(ErrorEventHandler)
remove_ExportBegin(ExportBeginEventHandler)
Declaration
public void remove_ExportBegin(ExportBeginEventHandler value)
Parameters
ExportBeginEventHandler
value
|
remove_InteractiveActionEnter(InteractiveActionEnterEventHandler)
Declaration
public void remove_InteractiveActionEnter(InteractiveActionEnterEventHandler value)
Parameters
InteractiveActionEnterEventHandler
value
|
remove_InteractiveActionExecuting(InteractiveActionExecutingEventHandler)
Declaration
public void remove_InteractiveActionExecuting(InteractiveActionExecutingEventHandler value)
Parameters
InteractiveActionExecutingEventHandler
value
|
remove_InteractiveActionLeave(InteractiveActionLeaveEventHandler)
Declaration
public void remove_InteractiveActionLeave(InteractiveActionLeaveEventHandler value)
Parameters
InteractiveActionLeaveEventHandler
value
|
remove_PrintBegin(CancelEventHandler)
Declaration
public void remove_PrintBegin(CancelEventHandler value)
Parameters
CancelEventHandler
value
|
remove_RenderBegin(RenderBeginEventHandler)
Declaration
public void remove_RenderBegin(RenderBeginEventHandler value)
Parameters
RenderBeginEventHandler
value
|
remove_RenderingBegin(CancelEventHandler)
Declaration
public void remove_RenderingBegin(CancelEventHandler value)
Parameters
CancelEventHandler
value
|
Events
ApplyParameters
Occurs when the viewer's Report property is changed, a parameter value is changed or refresh / preview is triggered from the viewer UI.
Declaration
public event ApplyParametersEventHandler ApplyParameters
Event Type
ApplyParametersEventHandler
|
Remarks
Use this event to change / add the parameter values that will be used in the upcoming render operation.
Examples
This example illustrates how to wire the ApplyParameters event and set values for specific parameters in the event handler.
void ReportViewer1_ApplyParameters(object sender, Telerik.ReportViewer.Silverlight.ApplyParametersEventArgs args)
{
//single value parameter
args.ParameterValues["ProductCategory"] = "Components";
//multi value parameter
args.ParameterValues["ProductSubcategory"] = new object[] { "Brakes", "Chains" };
//non-mergeable parameter value for first (0-based) parameter occurrence in a report book
args.ParameterValues["report(0).ProductCategory"] = "Components";
}
Private Sub ReportViewer1_ApplyParameters(sender As Object, args As Telerik.ReportViewer.Silverlight.ApplyParametersEventArgs)
'single value parameter
args.ParameterValues("ProductCategory") = "Components"
'multi value parameter
args.ParameterValues("ProductSubcategory") = New Object() {"Brakes", "Chains"}
'non-mergeable parameter value for first (0-based) parameter occurrence in a report book
args.ParameterValues("report(0).ProductCategory") = "Components"
End Sub
Error
Occurs when there is an error in the report viewer control.
Declaration
public event ErrorEventHandler Error
Event Type
ErrorEventHandler
|
Examples
This example illustrates how to wire the Error event and use the event arguments to check the exception.
void ReportViewer1_Error(object sender, Telerik.ReportViewer.Silverlight.ErrorEventArgs args)
{
if (args.Exception is System.Exception) // check for a specific exception
{
var message = args.Exception.Message;
// do something with the message and/or the
}
}
Private Sub ReportViewer1_Error(sender As Object, args As Telerik.ReportViewer.Silverlight.ErrorEventArgs)
If TypeOf args.Exception Is System.Exception Then
' check for a specific exception
' do something with the message and/or the
Dim message = args.Exception.Message
End If
End Sub
ExportBegin
Occurs when the report in the viewer control starts exporting.
Declaration
public event ExportBeginEventHandler ExportBegin
Event Type
ExportBeginEventHandler
|
Examples
This example illustrates how to wire the ExportBegin event, cancel it if needed and perform some logic based on the export format.
void ReportViewer1_ExportBegin(object sender, Telerik.ReportViewer.Silverlight.ExportBeginEventArgs args)
{
if (true) // some logic here
{
// Cancel is false by default
args.Cancel = true;
}
switch (args.Format)
{
case "Excel":
// do something
break;
case "PDF":
// do something
break;
}
}
Private Sub ReportViewer1_ExportBegin(sender As Object, args As Telerik.ReportViewer.Silverlight.ExportBeginEventArgs)
If True Then
' some logic here
' Cancel is false by default
args.Cancel = True
End If
Select Case args.Format
Case "Excel"
' do something
Exit Select
Case "PDF"
' do something
Exit Select
End Select
End Sub
ExportEnd
Occurs when the report exporting in the viewer control is finished.
Declaration
public event EventHandler ExportEnd
Event Type
System.EventHandler
|
Examples
This example illustrates how to wire the ExportEnd event.
void ReportViewer1_ExportEnd(object sender, System.EventArgs e)
{
// suitable for logging and triggering other actions
}
Private Sub ReportViewer1_ExportEnd(sender As Object, e As System.EventArgs)
' suitable for logging and triggering other actions
End Sub
InteractiveActionEnter
Occurs when the mouse cursor enters the area of a report item's action.
Declaration
public event InteractiveActionEnterEventHandler InteractiveActionEnter
Event Type
InteractiveActionEnterEventHandler
|
Examples
void ReportViewer1_InteractiveActionEnter(object sender, InteractiveActionEventArgs args)
{
var strB = new System.Text.StringBuilder();
strB.AppendLine("You have just entered an action area.");
strB.AppendLine("Action type: " + args.Action.Type);
strB.AppendLine("ReportItem name: " + args.Action.ReportItemName);
strB.AppendLine(string.Format("Mouse cursor position: {0}; Item bounds: {1}", args.CursorPos, args.Bounds));
Console.Out.WriteLine(strB.ToString());
}
' Handles the InteractiveActionEnter event
Private Sub ReportViewer1_InteractiveActionEnter(sender As Object, args As InteractiveActionEventArgs) Handles ReportViewer1.InteractiveActionEnter
Dim strB = New System.Text.StringBuilder()
strB.AppendLine("You have just entered an action area.")
strB.AppendLine("Action type: " + args.Action.[GetType]().Name)
strB.AppendLine("ReportItem name: " + args.Action.ReportItemName)
strB.AppendLine(String.Format("Mouse cursor position: {0}; Item bounds: {1}", args.CursorPos, args.Bounds))
Console.Out.WriteLine(strB.ToString())
End Sub
InteractiveActionExecuting
Occurs when an action is being executed. Execution can be canceled.
Declaration
public event InteractiveActionExecutingEventHandler InteractiveActionExecuting
Event Type
InteractiveActionExecutingEventHandler
|
Examples
This example illustrates how to wire the ActionExecuted event and use the event arguments
// Handles the InteractiveActionExecuting event
void ReportViewer1_CustomInteractiveActionExecuting(object sender, InteractiveActionCancelEventArgs args)
{
var strB = new System.Text.StringBuilder();
strB.AppendLine("ReportItem name: " + args.Action.ReportItemName);
if (args.Action.Type == Telerik.Reporting.Service.ActionType.CustomAction)
{
foreach (var p in args.Action.Parameters)
{
strB.AppendLine(string.Format("Parameter \"{0}\" value: {1}", p.Key, p.Value));
}
}
strB.AppendLine(string.Format("Mouse cursor position: {0}; Item bounds: {1}", args.CursorPos, args.Bounds));
System.Diagnostics.Debug.WriteLine(strB.ToString());
}
// Handles the InteractiveActionExecuting event
void ReportViewer1_CancelingInteractiveActionExecuting(object sender, InteractiveActionCancelEventArgs args)
{
if (args.Action.Type == Telerik.Reporting.Service.ActionType.UrlNavigation)
{
if (!args.Action.Url.StartsWith("https"))
{
args.Cancel = MessageBox.Show("You are about to navigate to a non-secure page. Continue?", "Warning", MessageBoxButton.OKCancel) != MessageBoxResult.OK;
}
}
}
' Handles the InteractiveActionExecuting event
Private Sub ReportViewer1_CustomInteractiveActionExecuting(sender As Object, args As InteractiveActionCancelEventArgs) Handles ReportViewer1.InteractiveActionExecuting
Dim strB = New System.Text.StringBuilder()
strB.AppendLine("ReportItem name: " + args.Action.ReportItemName)
If args.Action.Type = Service.ActionType.CustomAction Then
For Each p As KeyValuePair(Of String, Object) In args.Action.Parameters
strB.AppendLine(String.Format("Parameter ""{0}"" value: {1}", p.Key, p.Value))
Next
End If
strB.AppendLine(String.Format("Mouse cursor position: {0}; Item bounds: {1}", args.CursorPos, args.Bounds))
MessageBox.Show(strB.ToString())
End Sub
' Handles the InteractiveActionExecuting event
Private Sub ReportViewer1_CancelingInteractiveActionExecuting(sender As Object, args As InteractiveActionCancelEventArgs) Handles ReportViewer1.InteractiveActionExecuting
If args.Action.Type = Telerik.Reporting.Service.ActionType.UrlNavigation Then
If Not args.Action.Url.StartsWith("https") Then
args.Cancel = MessageBox.Show("You are about to navigate to a non-secure page. Continue?", "Warning", MessageBoxButton.OKCancel) <> MessageBoxResult.OK
End If
End If
End Sub
InteractiveActionLeave
Occurs when the mouse cursor leaves the area of a report item's action.
Declaration
public event InteractiveActionLeaveEventHandler InteractiveActionLeave
Event Type
InteractiveActionLeaveEventHandler
|
Examples
void ReportViewer1_InteractiveActionLeave(object sender, InteractiveActionEventArgs args)
{
var strB = new System.Text.StringBuilder();
strB.AppendLine("You have just left an action area.");
strB.AppendLine("Action type: " + args.Action.Type);
strB.AppendLine("ReportItem name: " + args.Action.ReportItemName);
strB.AppendLine(string.Format("Item bounds: {0}", args.Bounds));
Console.Out.WriteLine(strB.ToString());
}
' Handles the InteractiveActionLeave event
Private Sub ReportViewer1_InteractiveActionLeave(sender As Object, args As InteractiveActionEventArgs) Handles ReportViewer1.InteractiveActionLeave
Dim strB = New System.Text.StringBuilder()
strB.AppendLine("You have just left an action area.")
strB.AppendLine("Action type: " + args.Action.[GetType]().Name)
strB.AppendLine("ReportItem name: " + args.Action.ReportItemName)
strB.AppendLine(String.Format("Item bounds: {0}", args.Bounds))
Console.Out.WriteLine(strB.ToString())
End Sub
PrintBegin
Occurs when the report in the viewer control starts printing.
Declaration
public event CancelEventHandler PrintBegin
Event Type
CancelEventHandler
|
Examples
This example illustrates how to wire the PrintBegin event and how to cancel it if needed.
void ReportViewer1_PrintBegin(object sender, Telerik.ReportViewer.Silverlight.CancelEventArgs e)
{
if (true) // some logic here
{
// Cancel is false by default
e.Cancel = true;
}
}
Private Sub ReportViewer1_PrintBegin(sender As Object, e As Telerik.ReportViewer.Silverlight.CancelEventArgs)
If True Then
' some logic here
' Cancel is false by default
e.Cancel = True
End If
End Sub
PrintEnd
Occurs when the report printing in the viewer control is finished.
Declaration
public event EventHandler PrintEnd
Event Type
System.EventHandler
|
Examples
This example illustrates how to wire the PrintEnd event.
void ReportViewer1_PrintEnd(object sender, System.EventArgs e)
{
// suitable for logging and triggering other actions
}
Private Sub ReportViewer1_PrintEnd(sender As Object, e As System.EventArgs)
' suitable for logging and triggering other actions
End Sub
RenderBegin
Occurs when the viewer's Report property is changed, a parameter value is changed or refresh/print is triggered from the viewer UI.
Declaration
public event RenderBeginEventHandler RenderBegin
Event Type
RenderBeginEventHandler
|
RenderingBegin
Occurs when the report rendering in the viewer control is started.
Declaration
public event CancelEventHandler RenderingBegin
Event Type
CancelEventHandler
|
Examples
This example illustrates how to wire the RenderingBegin event and how to cancel it if needed.
void ReportViewer1_RenderingBegin(object sender, Telerik.ReportViewer.Silverlight.CancelEventArgs e)
{
if (true) // some logic here
{
// Cancel is false by default
e.Cancel = true;
}
}
Private Sub ReportViewer1_RenderingBegin(sender As Object, e As Telerik.ReportViewer.Silverlight.CancelEventArgs)
If True Then
' some logic here
' Cancel is false by default
e.Cancel = True
End If
End Sub
RenderingEnd
Occurs when the report rendering in the viewer control is finished.
Declaration
public event EventHandler RenderingEnd
Event Type
System.EventHandler
|
Examples
This example illustrates how to wire the RenderingEnd event.
void ReportViewer1_RenderingEnd(object sender, System.EventArgs e)
{
// suitable for logging and triggering other actions
}
Private Sub ReportViewer1_RenderingEnd(sender As Object, e As System.EventArgs)
' suitable for logging and triggering other actions
End Sub
UpdateUI
Occurs when the UI of the report viewer control is updated.
Declaration
public event EventHandler UpdateUI
Event Type
System.EventHandler
|
Examples
This example illustrates how to wire the UpdateUI event.
void ReportViewer1_UpdateUI(object sender, System.EventArgs e)
{
// invoked whenever the viewer state is changed
}
Private Sub ReportViewer1_UpdateUI(sender As Object, e As System.EventArgs)
' invoked whenever the viewer state is changed
End Sub
Explicit Interface Implementations
IReportServiceClientFactory.Create(Uri)
Declaration
ReportServiceClient IReportServiceClientFactory.Create(Uri remoteAddress)
Parameters
System.Uri
remoteAddress
|
Returns
ReportServiceClient
|