Skip to main content

DevExpress v25.1 Update — Your Feedback Matters

Our What's New in v25.1 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

XRControl.NavigateUrl Property

Bindable. Specifies the URL to navigate to when a control is clicked.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v25.1.dll

NuGet Package: DevExpress.Reporting.Core

#Declaration

[DefaultValue("")]
[SRCategory(ReportStringId.CatNavigation)]
public virtual string NavigateUrl { get; set; }

#Property Value

Type Default Description
String String.Empty

A string that corresponds to a URL.

#Remarks

Use the NavigateUrl property to set the URL for a control. When users click the control, the browser navigates to the specified web page. Start the URL with “http://“ or “https://“. Use the control’s Target property to specify a window or frame where the browser opens the new page.

You can also set the NavigateUrl property to an absolute or relative file path if you want to link to a file.

Set the Target property to _self to create a link within the same document. For this, set NavigateUrl to the value of the target control’s Name property. Please note that you cannot use expressions to assign the target control’s Name property to the NavigateURL property.

For more information, review the following help topic: Add Cross-References and Hyperlinks.

Note

Not all report controls (XRControl class descendants) have the NavigateUrl property. For example, this property is hidden for Band class descendants.

#Specify Execution Policy for User-Invoked Processes

When you click a control with a specified NavigateUrl property, a new process stats. For example, if the property points to a web page, the browser is opened. If it points to a .txt file, the text editor opens.

You can specify an execution policy for processes users initiate to avoid possible security issues. To do that, call a method of the ProcessStartPolicy class at application startup:

SuppressAll()

Applies a policy that suppresses all new processes.

You can click controls with a specified NavigateUrl property but no processes are executed.

ThrowAlways()
Applies a policy that throws an exception when a process is about to start.
RequireConfirmation()
Applies a policy that displays a confirmation dialog that prompts a user to confirm or cancel a process.

If you do not call any of these methods, processes are not affected when you click a control.

The following code suppresses all processes users initiate:

static void Main() {  
    DevExpress.Data.Utils.ProcessStartPolicy.SuppressAll();  
    //...  
} 

#Bind to Data

You can bind the NavigateUrl property to a data field in a report’s data source. For more information, refer to the following article: Bind Report Controls to Data.

#Example

This example demonstrates how to use the XRLabel control to create a hyperlink.

The code below creates the XRLabel control, sets up its appearance, and specifies its NavigateUrl and Target properties.

using System.Drawing;
using DevExpress.XtraReports.UI;
// ...

public XRLabel CreateHyperlink(){
    // Create a label for a hyperlink.
    XRLabel hyperlinkLabel = new XRLabel();

    // Set its main properties.
    hyperlinkLabel.Text = "DevExpress Inc.";
    hyperlinkLabel.Width = 200;
    hyperlinkLabel.ForeColor = Color.Blue;
    hyperlinkLabel.Font = new Font("Tahoma", 12, FontStyle.Underline);

    // Set its URL and target.
    hyperlinkLabel.NavigateUrl = "https://www.devexpress.com/";
    hyperlinkLabel.Target = "_blank";

    return hyperlinkLabel;
}

To add the hyperlink to the report’s Detail band, handle the report’s BeforePrint event:

using DevExpress.XtraReports.UI;
// ...

private void XtraReport1_BeforePrint(object sender, System.ComponentModel.EventArgs e) {
    // Create a new hyperlink and add it to the report's Detail Band.
    Bands.GetBandByType(typeof(DetailBand)).Controls.Add(CreateHyperlink());
}

The label behaves like a hyperlink in a report’s Print Preview and in a document exported to HTML, PDF, RTF, XLS, and XLSX formats.

See Also