A newer version of this page is available. Switch to the current version.

LabelControl.HyperlinkClick Event

Occurs whenever an end-user clicks a hyperlink contained within the current LabelControl.

Namespace: DevExpress.XtraEditors

Assembly: DevExpress.XtraEditors.v19.1.dll

Declaration

[DXCategory("Action")]
public event HyperlinkClickEventHandler HyperlinkClick
<DXCategory("Action")>
Public Event HyperlinkClick As HyperlinkClickEventHandler

Event Data

The HyperlinkClick event's data class is DevExpress.Utils.HyperlinkClickEventArgs.

Remarks

You can add hyperlinks to your LabelControl along with a regular text string. To do so, set the LabelControl.AllowHtmlString property to true and format the required text with the <href></href> tag. To see the list of all available tags, refer to HTML Text Formatting.

When an end-user clicks the hyperlink, the HyperlinkClick event occurs. Handle it to perform specific operations, depending on the link.

Examples

The following example shows how to format a LabelControl's text using HTML tags. HTML formatting is enabled via the LabelControl.AllowHtmlString property. To respond to an end-user clicking the hyperlink, the LabelControl.HyperlinkClick event is handled. The image below shows the result:

label_HTML_formatting

labelControl1.Text = "<size=14>Size = 14<br>" +
                     "<b>Bold</b> <i>Italic</i> <u>Underline</u><br>" + 
                     "<size=11>Size = 11<br>" + 
                     "<color=255, 0, 0>Sample Text</color></size>" +
                     "<href=www.devexpress.com>Hyperlink</href>";
labelControl1.AllowHtmlString = true;
labelControl1.Appearance.TextOptions.WordWrap = DevExpress.Utils.WordWrap.Wrap;
labelControl1.Appearance.Options.UseTextOptions = true;
labelControl1.AutoSizeMode = DevExpress.XtraEditors.LabelAutoSizeMode.Vertical;

private void labelControl1_HyperlinkClick(object sender, DevExpress.Utils.HyperlinkClickEventArgs e) {
    System.Diagnostics.Process.Start(e.Link);
}
See Also