HyperLinkEdit Class

The editor to display and edit hyperlinks and navigate to their targets.

Namespace: DevExpress.XtraEditors

Assembly: DevExpress.XtraEditors.v20.1.dll


public class HyperLinkEdit :
Public Class HyperLinkEdit
    Inherits ButtonEdit


A hyperlink editor presents its contents as a hyperlink. The text displayed in the edit box is underlined. When you activate the hyperlink functionality, the editor executes the command specified by the HyperLinkEdit.Text property.


The text displayed in the edit box may not match the command to execute. The display text is determined by the RepositoryItemHyperLinkEdit.Caption property. If the property represents an empty string, the display text matches the editor's HyperLinkEdit.Text property. Otherwise, the display text is determined by the RepositoryItemHyperLinkEdit.Caption. Note if the RepositoryItemHyperLinkEdit.Caption is set to a non-empty string, the end-user is not able to modify the editor's contents.

By default, the RepositoryItemHyperLinkEdit.TextEditStyle property is set to TextEditStyles.DisableTextEditor. This prevents the end-user from modifying and selecting the text. In order to enable editing and text selection, set the property to TextEditStyles.Standard.

The command in the HyperLinkEdit.Text property can represent any valid command recognized by the system. For instance, HyperLinkEdit.Text can specify:

  • a URL to open in the default browser ("www.devexpress.com")
  • a "mailto:" command which activates the default mail client ("mailto:support@devexpress.com")
  • a path to a file or directory to open ("c:\Program Files", "\Server\Public\setup.exe")

To activate the hyperlink functionality, you can:

The hyperlink editor provides a RepositoryItemHyperLinkEdit.OpenLink event to control hyperlink execution. Using this event, you can perform an action not recognized by the system, modify the command to execute, etc. For instance, if the hyperlink editor contains an e-mail without the "mailto:" prefix, the default hyperlink processing will do nothing. However, you can handle the RepositoryItemHyperLinkEdit.OpenLink event in order to make up a valid command by adding a "mailto:" prefix.


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();
See Also