ClassReportViewerBase
Definition
Namespace:Telerik.ReportViewer.WinForms
Assembly:Telerik.ReportViewer.WinForms.dll
Syntax:
[Docking(DockingBehavior.AutoDock)]
public abstract class ReportViewerBase : UserControl
Inheritance: objectMarshalByRefObjectComponentControlScrollableControlContainerControlUserControlReportViewerBase
Derived Classes:
Properties
AccessibilityKeyMap
Gets or sets the accessibility key shortcuts map, used when the report viewer is in accessible mode. Returns null reference if the viewer's accessibility is not enabled.
Declaration
[Browsable(false)]
public Dictionary<int, ShortcutKeys> AccessibilityKeyMap { get; set; }
Property Value
Dictionary<int, ShortcutKeys>
AllowNavigatingToFileUrls
Gets or sets a value that determines whether the execution of NavigateToURL action that points to a file is allowed. If set to false, navigating to local or network file from NavigateToUrl action will be disabled. If set to true, navigating to local or network file from NavigateToUrl action will show a confirmation window before executing the action. Default value: false
Declaration
public bool AllowNavigatingToFileUrls { get; set; }
Property Value
bool
CurrentPage
Gets or sets the current page in the viewer.
Declaration
[Browsable(false)]
public int CurrentPage { get; set; }
Property Value
int
Example
// 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
bool
Example
' 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;
}
EnableAccessibility
Gets or sets a value that indicates whether the accessibility features of the report viewer and its contents should be enabled.
Declaration
public bool EnableAccessibility { get; set; }
Property Value
bool
Remarks
Default value: false
NavigateBackEnabled
Determines if navigate back in report viewer history operation is enabled
Declaration
[Browsable(false)]
public bool NavigateBackEnabled { get; }
Property Value
bool
Example
// Navigate to the previous report in the history if available
private void button7_Click(object sender, System.EventArgs e)
{
if (this.reportViewer1.NavigateBackEnabled)
{
this.reportViewer1.NavigateBack();
}
}
' Navigate to the previous report in the history if available
Private Sub button7_Click(sender As Object, e As System.EventArgs)
If Me.ReportViewer1.NavigateBackEnabled Then
Me.ReportViewer1.NavigateBack()
End If
End Sub
NavigateForwardEnabled
Determines if navigate forward in report viewer history operation is enabled
Declaration
[Browsable(false)]
public bool NavigateForwardEnabled { get; }
Property Value
bool
Example
// Navigate to the next report in the history if available
private void button8_Click(object sender, System.EventArgs e)
{
if (this.reportViewer1.NavigateBackEnabled)
{
this.reportViewer1.NavigateBack();
}
}
' Navigate to the next report in the history if available
Private Sub button8_Click(sender As Object, e As System.EventArgs)
If Me.ReportViewer1.NavigateBackEnabled Then
Me.ReportViewer1.NavigateBack()
End If
End Sub
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
bool
Example
' 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;
}
ProcessingState
Gets the current processing state of the viewer
Declaration
[Browsable(false)]
public ProcessingState ProcessingState { get; }
Property Value
RenderingExtensions
Gets the available rendering extensions list.
Declaration
[Browsable(false)]
public IEnumerable<RenderingExtension> RenderingExtensions { get; }
Property Value
IEnumerable<RenderingExtension>
Report
Gets or sets the report displayed in the viewer.
Declaration
[Browsable(false)]
[Obsolete("Telerik.ReportViewer.WinForms.ReportViewer.Report is now obsolete. Please use the Telerik.ReportViewer.WinForms.ReportViewer.ReportSource property instead. For more information, please visit: https://www.telerik.com/support/kb/reporting/general/q2-2012-api-changes-reportsources.aspx#winformsviewer.")]
public IReportDocument Report { get; set; }
Property Value
ReportEngineConnection
The connection string used to configure the reporting engine that will process and render the reports.
Declaration
public string ReportEngineConnection { get; set; }
Property Value
string
Remarks
If the selected engine is of remote type (REST Service or Report Server), the following extra dependencies are required:
- Telerik.Reporting.Services.HttpClient
- System.Net.Http
- System.Net.Http.Formatting
Note: Connecting to Report Server for .NET is not supported yet.
Example
private void SetEmbeddedReportEngineConnection(object sender, System.EventArgs e)
{
this.reportViewer1.ReportEngineConnection = new Telerik.ReportViewer.Common.EmbeddedConnectionInfo().ConnectionString;
//if the ReportEngineConnection property is set to null or empty string, it will use the EmbeddedConnectionInfo by default.
}
Private Sub SetEmbeddedReportEngineConnection(sender As Object, e As System.EventArgs)
Me.ReportViewer1.ReportEngineConnection = New Telerik.ReportViewer.Common.EmbeddedConnectionInfo().ConnectionString
'if the ReportEngineConnection property is set to null or empty string, it will use the EmbeddedReportEngineConnectionInfo by default.
End Sub
private void SetReportServerReportEngineConnection(object sender, System.EventArgs e)
{
this.reportViewer1.ReportEngineConnection = new Telerik.ReportViewer.Common.ReportServerConnectionInfo("http://reportserver:83", "user", "pass", 20).ConnectionString;
}
Private Sub SetEmbeddedReportEngineConnection(sender As Object, e As System.EventArgs)
Me.ReportViewer1.ReportEngineConnection = New Telerik.ReportViewer.Common.EmbeddedConnectionInfo().ConnectionString
'if the ReportEngineConnection property is set to null or empty string, it will use the EmbeddedReportEngineConnectionInfo by default.
End Sub
private void SetRestServiceReportEngineConnection(object sender, System.EventArgs e)
{
this.reportViewer1.ReportEngineConnection = new Telerik.ReportViewer.Common.RestServiceConnectionInfo("http://servicehost:83/api/reports", "authToken", 20).ConnectionString;
}
Private Sub SetEmbeddedReportEngineConnection(sender As Object, e As System.EventArgs)
Me.ReportViewer1.ReportEngineConnection = New Telerik.ReportViewer.Common.EmbeddedConnectionInfo().ConnectionString
'if the ReportEngineConnection property is set to null or empty string, it will use the EmbeddedReportEngineConnectionInfo by default.
End Sub
ReportSource
Gets or sets the ReportSource for the report displayed in the viewer. Set this property in order to change the report shown in the viewer. The RefreshReport() method must be called in order to invoke the actual report change in the viewer.
Declaration
public ReportSource ReportSource { get; set; }
Property Value
ReportViewerModel
Gets the ReportViewerModel instance.
Declaration
public IReportViewerModel ReportViewerModel { get; }
Property Value
Resources
Declaration
[TypeConverter(typeof(ExpandableObjectConverter))]
public Resources Resources { get; }
Property Value
SearchMetadataOnDemand
Gets or sets a value that indicates whether the search metadata will be delivered on demand or by default.
Declaration
public bool SearchMetadataOnDemand { get; set; }
Property Value
bool
Remarks
Enabling search will notify the report engine to produce search metadata while rendering the report. This metadata is used by the report viewer in search dialog and in the report viewer area for highlighting the found and selected items. Default value: false
ShowDocumentMapButton
Indicates whether DocumentMap button should be visible.
Declaration
public bool ShowDocumentMapButton { get; set; }
Property Value
bool
ShowExportButton
Indicates whether Export button should be visible.
Declaration
public bool ShowExportButton { get; set; }
Property Value
bool
ShowHistoryButtons
Indicates whether the history (Back, Forward) buttons should be visible.
Declaration
public bool ShowHistoryButtons { get; set; }
Property Value
bool
ShowPageNavigationControls
Indicates whether the page navigation controls are visible.
Declaration
public bool ShowPageNavigationControls { get; set; }
Property Value
bool
ShowPageSetup
Indicates whether PageSetup button should be visible.
Declaration
[Obsolete("Use ReportViewerBase.ShowPageSetupButton property instead.")]
[Browsable(false)]
public bool ShowPageSetup { get; set; }
Property Value
bool
ShowPageSetupButton
Indicates whether PageSetup button should be visible.
Declaration
public bool ShowPageSetupButton { get; set; }
Property Value
bool
ShowParametersButton
Indicates whether Parameters button should be visible.
Declaration
public bool ShowParametersButton { get; set; }
Property Value
bool
ShowPrintButton
Indicates whether Print button should be visible.
Declaration
public bool ShowPrintButton { get; set; }
Property Value
bool
ShowPrintPreviewButton
Indicates whether PrintPreview button should be visible.
Declaration
public bool ShowPrintPreviewButton { get; set; }
Property Value
bool
ShowProgress
Indicates whether progress animation should be displayed while the report is rendered.
Declaration
public bool ShowProgress { get; set; }
Property Value
bool
ShowRefreshButton
Indicates whether the Refresh button should be visible.
Declaration
public bool ShowRefreshButton { get; set; }
Property Value
bool
ShowSearchButton
Indicates whether Search button should be visible.
Declaration
public bool ShowSearchButton { get; set; }
Property Value
bool
Remarks
If the button is visible, it will set the viewer's EnableSearch property to true, when pressed.
ShowStopButton
Indicates whether the Stop button should be visible.
Declaration
public bool ShowStopButton { get; set; }
Property Value
bool
ShowZoom
Indicates whether the Zoom input box should be visible.
Declaration
public bool ShowZoom { get; set; }
Property Value
bool
ToolbarVisible
Indicates whether the toolbar should be visible on the viewer.
Declaration
public bool ToolbarVisible { get; set; }
Property Value
bool
TotalPages
Gets the count of the available pages in the viewer.
Declaration
[Browsable(false)]
public int TotalPages { get; }
Property Value
int
Example
' 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;
}
ViewMode
Specifies whether the viewer is in interactive or print preview mode.
Declaration
public ViewMode ViewMode { get; set; }
Property Value
Example
' Switch to interactive mode
Private Sub button12_Click(sender As Object, e As System.EventArgs)
Me.ReportViewer1.ViewMode = Telerik.ReportViewer.WinForms.ViewMode.Interactive
End Sub
// Switch to interactive mode
private void button12_Click(object sender, System.EventArgs e)
{
this.reportViewer1.ViewMode = Telerik.ReportViewer.WinForms.ViewMode.Interactive;
}
ZoomMode
Gets or sets the zoom mode of the viewer.
Declaration
public ZoomMode ZoomMode { get; set; }
Property Value
Example
' Set the zoom mode to PageWidth
Private Sub button14_Click(sender As Object, e As System.EventArgs)
Me.ReportViewer1.ZoomMode = Telerik.ReportViewer.WinForms.ZoomMode.PageWidth
End Sub
// Set the zoom mode to PageWidth
private void button14_Click(object sender, System.EventArgs e)
{
this.reportViewer1.ZoomMode = Telerik.ReportViewer.WinForms.ZoomMode.PageWidth;
}
ZoomPercent
Gets or sets the percentage of zoom used for the report display.
Declaration
public int ZoomPercent { get; set; }
Property Value
int
Example
' Set the zoom percent to a specific value
Private Sub button13_Click(sender As Object, e As System.EventArgs)
Me.ReportViewer1.ZoomMode = Telerik.ReportViewer.WinForms.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.WinForms.ZoomMode.Percent;
this.reportViewer1.ZoomPercent = 140;
}
Methods
AddToRenderingContext(IDictionary)
Declaration
protected virtual void AddToRenderingContext(IDictionary renderingContext)
Parameters
renderingContext
IDictionary
CanMoveToPage(int)
Determines whether the viewer can be navigated to a specified page.
Declaration
public bool CanMoveToPage(int pageIndex)
Parameters
pageIndex
int
The page number to determine navigation possibility.
Returns
bool
Returns true if the viewer can be moved to the specified page.
Example
// 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
CancelRendering()
Stops the background processing of the report.
Declaration
public void CancelRendering()
Example
// Stop rendering the report.
private void button1_Click(object sender, System.EventArgs e)
{
this.reportViewer1.CancelRendering();
}
' Stop rendering the report.
Private Sub button1_Click(sender As Object, e As System.EventArgs)
Me.ReportViewer1.CancelRendering()
End Sub
CancelRendering(int)
Stops background processing of the report.
Declaration
[Obsolete("CancelRendering(int timeout) method is now obsolete. Please use the Telerik.ReportViewer.WinForms.ReportViewer.CancelRendering() method instead.")]
public bool CancelRendering(int timeout)
Parameters
timeout
int
The number of milliseconds to wait for the background rendering to terminate. A value of -1 waits forever. A value of 0 returns immediately without waiting for the rendering to terminate.
Returns
bool
A Boolean value. A value of true is returned if the background rendering has terminated. A value of false is returned if background rendering has not terminated after the amount of time specified in the millisecondsTimeout parameter has elapsed, or if the millisecondsTimeout parameter was set to 0.
ClearHistory()
Clears the report viewer navigation history.
Declaration
public void ClearHistory()
Remarks
Use this method to remove all viewer history records generated:
- From RefreshReport() method after the ReportSource property is changed.
- From Preview() method with different parameter values.
- From NavigateToReportAction interactivity action.
Dispose(bool)
Declaration
protected override void Dispose(bool disposing)
Parameters
disposing
bool
Overrides
ExportReport(string, Hashtable)
Exports the report in the specified format.
Declaration
public void ExportReport(string format, Hashtable deviceInfo)
Parameters
format
string
Export format
deviceInfo
Hashtable
Contains parameters to pass to the rendering extension.
Example
// 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
FormatNavigateToFileConfirmation(string)
Declaration
protected string FormatNavigateToFileConfirmation(string url)
Parameters
url
string
Returns
string
HandleNavigateToFileActionNotSupported(NotSupportedException)
virtual for test purposes only.
Declaration
protected virtual void HandleNavigateToFileActionNotSupported(NotSupportedException nsx)
Parameters
nsx
NotSupportedException
NavigateBack()
Navigates the viewer back one step in the navigation history.
Declaration
public void NavigateBack()
Remarks
Check NavigateBackEnabled if this operation is enabled.
If not, exception is thrown.
The ReportSource property will reflect the change in the
currently shown report.
Example
// Navigate to the previous report in the history if available
private void button7_Click(object sender, System.EventArgs e)
{
if (this.reportViewer1.NavigateBackEnabled)
{
this.reportViewer1.NavigateBack();
}
}
' Navigate to the previous report in the history if available
Private Sub button7_Click(sender As Object, e As System.EventArgs)
If Me.ReportViewer1.NavigateBackEnabled Then
Me.ReportViewer1.NavigateBack()
End If
End Sub
NavigateForward()
Navigates the viewer forward one step in the navigation history.
Declaration
public void NavigateForward()
Remarks
Check NavigateForwardEnabled if this operation is enabled.
If not, exception is thrown.
The ReportSource property will reflect the change in the
currently shown report.
Example
// Navigate to the next report in the history if available
private void button8_Click(object sender, System.EventArgs e)
{
if (this.reportViewer1.NavigateBackEnabled)
{
this.reportViewer1.NavigateBack();
}
}
' Navigate to the next report in the history if available
Private Sub button8_Click(sender As Object, e As System.EventArgs)
If Me.ReportViewer1.NavigateBackEnabled Then
Me.ReportViewer1.NavigateBack()
End If
End Sub
OnError(ErrorEventArgs)
Raises the Error event.
Declaration
protected virtual void OnError(ErrorEventArgs e)
Parameters
e
The ErrorEventArgs 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
e
The ExportBeginEventArgs that contains the event data.
Remarks
When overridden, make sure you call the base method implementation.
OnExportEnd(ExportEndEventArgs)
Raises the ExportEnd event.
Declaration
protected virtual void OnExportEnd(ExportEndEventArgs e)
Parameters
e
The ExportEndEventArgs 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
e
The InteractiveActionEventArgs that contains the event data.
OnInteractiveActionExecuting(InteractiveActionCancelEventArgs)
Raises the InteractiveActionExecuting event.
Declaration
protected virtual void OnInteractiveActionExecuting(InteractiveActionCancelEventArgs e)
Parameters
e
InteractiveActionCancelEventArgs
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
e
The InteractiveActionEventArgs that contains the event data.
OnLoad(EventArgs)
Declaration
protected override void OnLoad(EventArgs e)
Parameters
e
EventArgs
Overrides
OnPrint(CancelEventArgs)
Raises the Print event.
Declaration
[Obsolete("OnPrint method is now obsolete. Please use Telerik.ReportViewer.WinForms.ReportViewer.OnPrintBegin method instead.")]
protected virtual void OnPrint(CancelEventArgs e)
Parameters
e
CancelEventArgs
The CancelEventArgs that contains the event data.
OnPrintBegin(CancelEventArgs)
Raises the Print event.
Declaration
[Obsolete("This overload is now obsolete. Please use Telerik.ReportViewer.WinForms.ReportViewer.OnPrintBegin(PrintBeginEventArgs) instead.")]
protected virtual void OnPrintBegin(CancelEventArgs e)
Parameters
e
CancelEventArgs
The CancelEventArgs that contains the event data.
Remarks
When overridden, make sure you call the base method implementation.
OnPrintBegin(PrintBeginEventArgs)
Raises the Print event.
Declaration
protected virtual void OnPrintBegin(PrintBeginEventArgs e)
Parameters
e
The PrintBeginEventArgs that contains the event data.
Remarks
When overridden, make sure you call the base method implementation.
OnPrintEnd(EventArgs)
Raises the PrintEnd event.
Declaration
[Obsolete("This overload is now obsolete. Please use Telerik.ReportViewer.WinForms.ReportViewer.OnPrintEnd(PrintEndEventArgs) instead.")]
protected virtual void OnPrintEnd(EventArgs e)
Parameters
e
EventArgs
The EventArgs that contains the event data.
Remarks
When overridden, make sure you call the base method implementation.
OnPrintEnd(PrintEndEventArgs)
Raises the PrintEnd event.
Declaration
protected virtual void OnPrintEnd(PrintEndEventArgs e)
Parameters
e
The PrintEndEventArgs that contains the event data.
Remarks
When overridden, make sure you call the base method implementation.
OnRenderingBegin(CancelEventArgs)
Raises the RenderingBegin event.
Declaration
[Obsolete("This overload is now obsolete. Please use Telerik.ReportViewer.WinForms.ReportViewer.OnRenderingBegin(RenderingBeginEventArgs) instead.")]
protected virtual void OnRenderingBegin(CancelEventArgs e)
Parameters
e
CancelEventArgs
The CancelEventArgs that contains the event data.
Remarks
When overridden, make sure you call the base method implementation.
OnRenderingBegin(RenderingBeginEventArgs)
Raises the RenderingBegin event.
Declaration
protected virtual void OnRenderingBegin(RenderingBeginEventArgs e)
Parameters
e
The RenderingBeginEventArgs that contains the event data.
Remarks
When overridden, make sure you call the base method implementation.
OnRenderingEnd(EventArgs)
Raises the RenderingEnd event.
Declaration
[Obsolete("This overload is now obsolete. Please use Telerik.ReportViewer.WinForms.ReportViewer.OnRenderingEnd(RenderingEndEventArgs) instead.")]
protected virtual void OnRenderingEnd(EventArgs e)
Parameters
e
EventArgs
The EventArgs that contains the event data.
Remarks
When overridden, make sure you call the base method implementation.
OnRenderingEnd(RenderingEndEventArgs)
Raises the RenderingEnd event.
Declaration
protected virtual void OnRenderingEnd(RenderingEndEventArgs e)
Parameters
e
The RenderingEndEventArgs that contains the event data.
Remarks
When overridden, make sure you call the base method implementation.
OnToolTipExecuting(ToolTipOpeningEventArgs)
Raises the ViewerToolTipOpening event.
Declaration
protected virtual void OnToolTipExecuting(ToolTipOpeningEventArgs e)
Parameters
e
The ToolTipOpeningEventArgs that contains the event data.
OnUpdateUI(EventArgs)
Raises the UpdateUI event.
Declaration
protected virtual void OnUpdateUI(EventArgs e)
Parameters
e
EventArgs
The EventArgs that contains the event data.
Remarks
When overridden, make sure you call the base method implementation.
Preview()
Renders the report in the viewer passing the currently entered parameter values to the report.
Declaration
public void Preview()
PrintReport()
Opens the print dialog for the report
Declaration
public void PrintReport()
Example
// 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
PrintReportInternal(Hashtable, PrintBeginEventArgs)
Declaration
protected void PrintReportInternal(Hashtable deviceInfo, PrintBeginEventArgs eventArgs)
Parameters
deviceInfo
Hashtable
eventArgs
ProcessCmdKey(ref Message, Keys)
Capture the keystrokes to determine if a valid accessible area shortcut is pressed
Declaration
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
Parameters
msg
Message
keyData
Keys
Returns
bool
Overrides
RefreshReport()
Loads and refreshes the ReportSource in the viewer.
Use this method to display in the viewer the report source
from the ReportSource property.
Fresh report data is pulled from the report source data sources.
Adds new history record in the report history right
after the current record and the new record becomes current.
This method should not be called before the Form.Load() event is fired
(avoid using it in the Form's constructor).
Declaration
public void RefreshReport()
Example
// 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
ShowNavigateToFileConfirmationDialog(string)
Declaration
protected virtual DialogResult ShowNavigateToFileConfirmationDialog(string url)
Parameters
url
string
Returns
DialogResult
ShowPageSetupDialog()
Opens the page setup dialog
Declaration
public void ShowPageSetupDialog()
ToggleReportContentSearch()
Toggles the search dialog to search within the document. If the search metadata is not prepared, invokes report refresh to generate the search metadata and then opens the dialog.
Declaration
public void ToggleReportContentSearch()
Events
AccessibilityChanged
Occurs when the EnableAccessibility property is changed.
Declaration
public event AccessibilityChangedEventHandler AccessibilityChanged
Event Value
Error
Occurs when there is an error in the report viewer control.
Declaration
public event ErrorEventHandler Error
Event Value
Example
This example illustrates how to wire the Error event and use the event arguments to check the exception.
void reportViewer1_Error(object sender, Telerik.Reporting.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.Reporting.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 Value
Remarks
Can be used to modify device info settings, such as report culture, before the export starts
Example
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.Common.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.Common.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 ExportEndEventHandler ExportEnd
Event Value
Example
This example illustrates how to wire the ExportEnd event.
void reportViewer1_ExportEnd(object sender, Telerik.ReportViewer.Common.ExportEndEventArgs args)
{
if (null != args.Exception)
{
//some logic if report processing is not successful
}
else
{
//suppress the viewer SaveFileDialog and use your own
args.Handled = true;
var fileName = args.DocumentName;
var extension = args.DocumentExtension;
var filter = string.Format("{0} (*.{1})|*.{1}|All Files (*.*)|*.*",
fileName,
extension);
var saveFileDlg = new SaveFileDialog
{
Filter = filter,
FileName = fileName + "." + extension,
};
if (saveFileDlg.ShowDialog() == DialogResult.OK)
{
try
{
using (var fs = new FileStream(saveFileDlg.FileName, FileMode.Create))
{
fs.Write(args.DocumentBytes, 0, args.DocumentBytes.Length);
}
//Optionally open the file
if (!string.IsNullOrEmpty(saveFileDlg.FileName))
{
System.Diagnostics.Process.Start(saveFileDlg.FileName);
}
}
catch (Exception)
{
//Handle exception
}
}
}
}
Private Sub reportViewer1_ExportEnd(sender As Object, args As Telerik.ReportViewer.Common.ExportEndEventArgs)
'some logic if report processing is not successful
If args.Exception IsNot Nothing Then
Else
'suppress the viewer SaveFileDialog and use your own
args.Handled = True
Dim fileName = args.DocumentName
Dim extension = args.DocumentExtension
Dim filter = String.Format("{0} (*.{1})|*.{1}|All Files (*.*)|*.*", fileName, extension)
Dim saveFileDlg = New SaveFileDialog() With { _
.Filter = filter, _
.FileName = fileName + "." + extension _
}
If saveFileDlg.ShowDialog() = DialogResult.OK Then
Try
Using fs = New FileStream(saveFileDlg.FileName, FileMode.Create)
fs.Write(args.DocumentBytes, 0, args.DocumentBytes.Length)
End Using
'Optionally open the file
If Not String.IsNullOrEmpty(saveFileDlg.FileName) Then
System.Diagnostics.Process.Start(saveFileDlg.FileName)
End If
'Handle exception
Catch generatedExceptionName As Exception
End Try
End If
End If
End Sub
InteractiveActionEnter
Occurs when the mouse cursor enters the area of a report item's action.
Declaration
public event InteractiveActionEnterEventHandler InteractiveActionEnter
Event Value
Example
This example illustrates how to wire the event and use the event arguments
void reportViewer1_InteractiveActionEnter(object sender, Telerik.ReportViewer.Common.InteractiveActionEventArgs args)
{
var 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());
}
' Handles the InteractiveActionEnter event
' Do not forget to add the WithEvents clause on ReportViewer1 instantiation if needed.
Private Sub reportViewer1_InteractiveActionEnter(sender As Object, args As Telerik.ReportViewer.Common.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 Value
Example
This example illustrates how to wire the event and use the event arguments.
void reportViewer1_CustomInteractiveActionExecuting(object sender, Telerik.ReportViewer.Common.InteractiveActionCancelEventArgs args)
{
var strB = new System.Text.StringBuilder();
strB.AppendLine("ReportItem name: " + args.Action.ReportItemName);
var customAction = args.Action as Telerik.Reporting.Processing.CustomAction;
if (null != customAction)
{
foreach (var p in customAction.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));
MessageBox.Show(strB.ToString());
}
void reportViewer1_InteractiveActionExecuting(object sender, Telerik.ReportViewer.Common.InteractiveActionCancelEventArgs args)
{
var navigateToUrlAction = args.Action as Telerik.Reporting.Processing.NavigateToUrlAction;
if (null != navigateToUrlAction)
{
if (!navigateToUrlAction.Url.StartsWith("https"))
{
args.Cancel = MessageBox.Show("You are about to navigate to a non-secure page. Continue?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != System.Windows.Forms.DialogResult.Yes;
}
}
}
' Handles the InteractiveActionExecuting event
' Do not forget to add the WithEvents clause on ReportViewer1 instantiation if needed.
Private Sub reportViewer1_CustomInteractiveActionExecuting(sender As Object, args As Telerik.ReportViewer.Common.InteractiveActionCancelEventArgs) Handles ReportViewer1.InteractiveActionExecuting
Dim strB = New System.Text.StringBuilder()
strB.AppendLine("ReportItem name: " + args.Action.ReportItemName)
Dim customAction = TryCast(args.Action, Telerik.Reporting.Processing.CustomAction)
If customAction IsNot Nothing Then
For Each p As KeyValuePair(Of String, Object) In customAction.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
' Do not forget to add the WithEvents clause on ReportViewer1 instantiation if needed.
Private Sub reportViewer1_CustomInteractiveActionExecuting(sender As Object, args As Telerik.ReportViewer.Common.InteractiveActionCancelEventArgs) Handles ReportViewer1.InteractiveActionExecuting
Dim strB = New System.Text.StringBuilder()
strB.AppendLine("ReportItem name: " + args.Action.ReportItemName)
Dim customAction = TryCast(args.Action, Telerik.Reporting.Processing.CustomAction)
If customAction IsNot Nothing Then
For Each p As KeyValuePair(Of String, Object) In customAction.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
InteractiveActionLeave
Occurs when the mouse cursor leaves the area of a report item's action.
Declaration
public event InteractiveActionLeaveEventHandler InteractiveActionLeave
Event Value
Example
This example illustrates how to wire the event and use the event arguments
void reportViewer1_InteractiveActionLeave(object sender, Telerik.ReportViewer.Common.InteractiveActionEventArgs args)
{
var 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());
}
' Handles the InteractiveActionLeave event
' Do not forget to add the WithEvents clause on ReportViewer1 instantiation if needed.
Private Sub reportViewer1_InteractiveActionLeave(sender As Object, args As Telerik.ReportViewer.Common.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
Occurs when the report in the viewer control is printed.
Declaration
[Obsolete("Print event is now obsolete. Please use Telerik.ReportViewer.WinForms.ReportViewer.PrintBegin event instead.")]
public event CancelEventHandler Print
Event Value
CancelEventHandler
PrintBegin
Occurs when the report in the viewer control starts printing.
Declaration
public event PrintBeginEventHandler PrintBegin
Event Value
Example
This example illustrates how to wire the PrintBegin event and how to cancel it if needed.
void reportViewer1_PrintBegin(object sender, Telerik.ReportViewer.Common.PrintBeginEventArgs e)
{
if (true) // some logic here
{
// Cancel is false by default
e.Cancel = true;
}
//To prevent the Print Dialog from appearing, you should specify valid printer settings to this method.
if (true)
{
// Obtain the settings of the default printer
e.PrinterSettings = new System.Drawing.Printing.PrinterSettings();
// To suppress the Print dialogs. The standard print controller comes with no UI
e.PrintController = new System.Drawing.Printing.StandardPrintController();
}
}
Private Sub reportViewer1_PrintBegin(sender As Object, e As Telerik.ReportViewer.Common.PrintBeginEventArgs)
If True Then
' some logic here
' Cancel is false by default
e.Cancel = True
End If
If True Then
e.PrinterSettings.Copies = 2
End If
' To prevent the Print Dialog from appearing, you should specify valid printer settings to this method.
If True Then
' Obtain the settings of the default printer
e.PrinterSettings = New System.Drawing.Printing.PrinterSettings()
' To suppress the Print dialogs. The standard print controller comes with no UI
e.PrintController = New System.Drawing.Printing.StandardPrintController()
End If
End Sub
PrintEnd
Occurs when the report printing in the viewer control is finished.
Declaration
public event PrintEndEventHandler PrintEnd
Event Value
Example
This example illustrates how to wire the PrintEnd event.
Private Sub reportViewer1_PrintEnd(sender As Object, e As Telerik.ReportViewer.Common.PrintEndEventArgs)
' suitable for logging and triggering other actions
End Sub
void reportViewer1_PrintEnd(object sender, Telerik.ReportViewer.Common.PrintEndEventArgs e)
{
// suitable for logging and triggering other actions
}
RenderingBegin
Occurs when the report in the viewer control starts rendering.
Declaration
public event RenderingBeginEventHandler RenderingBegin
Event Value
Remarks
Can be used to modify device info settings, such as report culture, before the rendering starts
Example
This example illustrates how to wire the RenderingBegin event and how to cancel it if needed.
void reportViewer1_RenderingBegin(object sender, Telerik.ReportViewer.Common.RenderingBeginEventArgs 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.Common.RenderingBeginEventArgs)
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 RenderingEndEventHandler RenderingEnd
Event Value
Example
This example illustrates how to wire the RenderingEnd event.
void reportViewer1_RenderingEnd(object sender, Telerik.ReportViewer.Common.RenderingEndEventArgs e)
{
// suitable for logging and triggering other actions
}
Private Sub reportViewer1_RenderingEnd(sender As Object, e As Telerik.ReportViewer.Common.RenderingEndEventArgs)
' 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 Value
EventHandler
Example
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
ViewerAreaPaint
Occurs when the viewer's area is painted.
Declaration
public event PaintEventHandler ViewerAreaPaint
Event Value
PaintEventHandler
ViewerToolTipOpening
Occurs when the tooltip, associated with a report item, is being opened
Declaration
public event ToolTipOpeningEventHandler ViewerToolTipOpening
Event Value
Example
This example illustrates how to wire the event, cancel tooltip showing and change tooltip's title and text.
private void reportViewer1_ViewerToolTipOpening(object sender, Telerik.ReportViewer.Common.ToolTipOpeningEventArgs args)
{
if (args.ToolTip.Title.Contains("DoNotShow"))
{
args.Cancel = true;
}
else
{
args.ToolTip.Title = "The tooltip title is changed!";
args.ToolTip.Text += " (changed)";
}
}
' Handles the ViewerToolTipOpening event
' Do not forget to add the WithEvents clause on ReportViewer1 instantiation if needed.
Private Sub reportViewer1_ViewerToolTipOpening(sender As Object, args As Telerik.ReportViewer.Common.ToolTipOpeningEventArgs) Handles ReportViewer1.ViewerToolTipOpening
If args.ToolTip.Title.Contains("DoNotShow") Then
args.Cancel = True
Else
args.ToolTip.Title = "The tooltip title is changed!"
args.ToolTip.Text += " (changed)"
End If
End Sub