How to handle hyperlink events in application
Hyperlink event allows to perform the customized action in your application when hyperlink is clicked in a report. The following section describes the details to add hyperlink to report and handle the customized action in application.
Adding a Hyperlink action
You can add a hyperlink to report items in RDL/RDLC reports with the help of Action properties. The below steps guide you to do this with the help of WPF Syncfusion Report Designer.
- In design view of report, right-click the report items, then click Properties.
- In the properties dialog, select Action tab and choose Go to URL options.
- In Select URL, specify the URL to need to navigate (Example: https://www.syncfusion.com/products/report).
- Click OK.
Handling event in application
The hyperlink event can be registered in XAML or code behind as like following code snippet,
XAML
<Grid> <sync:ReportViewer x:Name="Viewer" ReportPath="../../Resources/GroupingAgg.rdl" ProcessingMode="Remote" Hyperlink="Hyperlink_clicked"/> </Grid>
C#
Viewer.Hyperlink += new HyperlinkEventHandler(Hyperlink_clicked);
You can implement the customized action in the event handler method and set Cancel argument as true to true to ignore the report action. The following demonstrates opening a new custom window in application when hyperlink action is raised.
C#
private void Hyperlink_clicked(object sender, HyperlinkEventArgs e) { e.Cancel = true; // Set Cancel to true, else it will launch the hyperlink provided in report. CustomWindow CustomWindow = new CustomWindow(); CustomWindow.Show(); CustomWindow.Owner = this; }
Output
Sample