Back to Devexpress

XRControl.Target Property

xtrareports-devexpress-dot-xtrareports-dot-ui-dot-xrcontrol-0fdbf5ad.md

latest5.4 KB
Original Source

XRControl.Target Property

Specifies the target window or frame in which to display the linked Web page’s content, when the control is clicked.

Namespace : DevExpress.XtraReports.UI

Assembly : DevExpress.XtraReports.v25.2.dll

NuGet Package : DevExpress.Reporting.Core

Declaration

csharp
[DefaultValue("")]
[SRCategory(ReportStringId.CatNavigation)]
public virtual string Target { get; set; }
vb
<SRCategory(ReportStringId.CatNavigation)>
<DefaultValue("")>
Public Overridable Property Target As String

Property Value

TypeDefaultDescription
StringString.Empty

A String which identifies the window or frame at which to target the URL’s content. Its values must begin with a letter in the range a through to z (case insensitive), except for the following special values, which begin with an underscore.

|

Remarks

When an XRControl object is clicked and its XRControl.NavigateUrl property is defined, a Web browser navigates to the URL specified by the latter, and displays it in the window or frame, as specified by the Target property. The available values of this property are listed in the table below.

MemberDescription
empty stringDefault. If the Target property is not set, the behavior is similar if the Target property is set to _blank.
nameThe name of the target window or frame.
_blankLoads the linked document into a new blank window. This window is not named.
_parentLoads the linked document into the immediate parent of the document containing the link.
_searchLoads the linked document into the browser search pane. Available in Internet Explorer 5 or later.
_selfLoads the linked document into the window in which the link was clicked (the active window).
_topLoads the linked document into the topmost window.

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.

csharp
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;
}
vb
Imports System.Drawing
Imports DevExpress.XtraReports.UI
' ...

Public Function CreateHyperlink() As XRLabel
    ' Create a label for a hyperlink.
    Dim hyperlinkLabel As XRLabel = 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
End Function

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

csharp
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());
}
vb
Imports DevExpress.XtraReports.UI
' ...

Private Sub XtraReport1_BeforePrint(ByVal sender As Object, ByVal e As System.ComponentModel.EventArgs)
    Create a new hyperlink and add it to the report's Detail Band.
    Bands.GetBandByType(GetType(DetailBand)).Controls.Add(CreateHyperlink())
End Sub

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

NavigateUrl

XRControl Class

XRControl Members

DevExpress.XtraReports.UI Namespace