Skip to main content
A newer version of this page is available. .

HyperLinkEdit.OpenLink Event

Occurs before hyperlink execution.

Namespace: DevExpress.XtraEditors

Assembly: DevExpress.XtraEditors.v18.2.dll

Declaration

Event Data

The OpenLink event's data class is OpenLinkEventArgs. The following properties provide information specific to this event:

Property Description
EditValue Gets or sets the object representing the command to execute.
Handled Gets or sets whether default execution of the hyperlink command is required.

Remarks

The OpenLink event is fired before hyperlink execution. The event lets you modify the command to execute, perform actions and to cancel default processing.

The editor’s OpenLink event is equivalent to the RepositoryItemHyperLinkEdit.OpenLink event available via the HyperLinkEdit.Properties object, i.e. adding/removing an event handler for the current event actually affects the RepositoryItemHyperLinkEdit.OpenLink event.

Refer to the RepositoryItemHyperLinkEdit.OpenLink topic for more information.

Example

Suppose that a hyperlink editor is used to display e-mails. When you activate the hyperlink, the default mail client should be opened for the specified address. The problem is that a hyperlink editor will run the mail client only if the command contains a “mailto:” prefix. So a command such as “support@devexpress.com” is not recognized by the editor by default.

Assuming that the hyperlink editor represents e-mails, we handle the HyperLinkEdit.OpenLink event and check whether the command contains the “mailto:” prefix. If not, we add it to the command. After the event handler is processed, the command will be executed by the editor (the OpenLinkEventArgs.Handled property of the event parameter is false by default) and this will open the mail client.

using DevExpress.XtraEditors.Controls;

this.hyperLinkEdit2.EditValue = "support@devexpress.com";
//...
private void hyperLinkEdit2_OpenLink(object sender, OpenLinkEventArgs e) {
    const string mailPrefix = "mailto:";
    if(!e.EditValue.ToString().ToLower().StartsWith(mailPrefix)) {
        e.EditValue = mailPrefix + e.EditValue.ToString();
    }
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the OpenLink event.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also