windowsforms-9490-controls-and-libraries-editors-and-simple-controls-examples-how-to-customize-hyperlinkedits-command-via-event.md
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 “[email protected]” 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 = "[email protected]";
//...
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();
}
}
Me.HyperLinkEdit2.EditValue = "[email protected]"
'...
Private Sub HyperLinkEdit2_OpenLink(ByVal sender As System.Object, _
ByVal e As DevExpress.XtraEditors.Controls.OpenLinkEventArgs) _
Handles HyperLinkEdit2.OpenLink
Const mailPrefix As String = "mailto:"
If Not e.EditValue.ToString().ToLower().StartsWith(mailPrefix) Then
e.EditValue = mailPrefix + e.EditValue.ToString()
End If
End Sub